...
Code Block |
---|
|
public class App extends Application {
private BroadcastReceiver sessionReadyReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
BuzzAdPopPedometer.init(context, "YOUR_POP_UNIT_ID");
}
};
@Override
public void onCreate() {
super.onCreate();
final PedometerConfig pedometerConfig = new PedometerConfig
.Builder(context, "YOUR_PEDOMETER_UNIT_ID_PEDOMETER", "YOUR_PEDOMETER_REWARD_UNIT_ID_PEDOMETER_REWARD")
.build();
final PopConfig popConfig = new PopConfig.Builder(getApplicationContext(), "YOUR_POP_UNIT_ID")
.feedHeaderViewAdapterClass(DefaultPedometerPopHeaderViewAdapter.class)
.popMode(PopConfig.PopMode.PEDOMETER_POP)
.pedometerConfig(pedometerConfig)
.build();
final BuzzAdBenefitConfig buzzAdBenefitConfig = new BuzzAdBenefitConfig.Builder(this)
.setPopConfig(popConfig)
.build();
BuzzAdBenefit.init(this, buzzAdBenefitConfig);
BuzzAdBenefit.registerSessionReadyBroadcastReceiver(this, sessionReadyReceiver);
}
} |
...
Code Block |
---|
|
@TargetApi(Build.VERSION_CODES.Q)
private void requestActivityRecognitionPermission(Activity activity) {
if (ActivityCompat.shouldShowRequestPermissionRationale(activity, Manifest.permission.ACTIVITY_RECOGNITION)) {
if (!activity.isFinishing()) {
new AlertDialog.Builder(activity)
.setTitle(R.string.your_title)
.setMessage(R.string.your_message)
.setPositiveButton(android.R.string.your_ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
requestPermissions(new String[]{Manifest.permission.ACTIVITY_RECOGNITION}, ACTIVATION_REQUEST_CODE);
}
}).show();
}
} else {
requestPermissions(new String[]{Manifest.permission.ACTIVITY_RECOGNITION}, ACTIVATION_REQUEST_CODE);
}
} |
만보기 활성화
권한을 얻었다면 획득한 후, Pop을 표시하고 만보기를 활성화 합니다활성화합니다.
Code Block |
---|
|
public class YourActivity extends AppCompatActivity {
@Override
public void onCreate() {
super.onCreate();
if (getIntent().getBooleanExtra(KEY_SETTINGS_RESULT, false) && getIntent().getIntExtra(KEY_SETTINGS_REQUEST_CODE, 0) == REQUEST_CODE_SHOW_POP) {
if (BuzzAdPop.hasPermission(this)) {
buzzAdPop.preloadAndShowPop();
BuzzAdPopPedometer.activate();
}
}
}
} |