我试图创建一个单一目的的应用程序。 所以我创建了一个BaseActivity,我的所有活动都从它继承。Android Studio,Kiosk模式,单用途设备,锁定任务模式
它看起来像
公共类LockDeviceActivity扩展AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
private void startLock() {
if(mDevicePolicyManager.isLockTaskPermitted(getPackageName())) {
/**
* If lock task is permitted, we can lock the task. We can use an external DPM like
* TestDPC provided by Google to manage lock task list.
*
* If the lock is obtained using TestDPC, features like status bar, home button, recent
* apps, etc is disabled.
*
* To unlock we can programatically call stopLockTask() when users taps a button. But
* in practice this should be done using a separate admin console or Confirm Credential.
*
* For API 23+ you can check if the lock is active by checking if
* activityManager.getLockTaskModeState() == ActivityManager.LOCK_TASK_MODE_NONE
*/
Log.d(TAG, "startLock() called");
this.startLockTask();
} else {
/**
* The device is not whitelisted.
*/
Toast.makeText(this, "The app is not whitelisted for lock", Toast.LENGTH_SHORT).show();
// Timber.d("The app is not whitelisted for lock task");
/**
* We can still pin the app but it will not be locked.
*
* We can simply unlock by pressing recent and back button together.
*
* Unlocking by calling stopLockTask() on button click can be achieved as well.
*/
// Timber.d("just pinning the app");
this.startLockTask();
}
}
所以当我第一次进入应用程序,我可以看到一些置顶消息,并通过我没关系。 问题是,当我在做从一个活动到含有片段其他活动的意图,我发现了以下图像:
加我得到一个某些系统吐司消息: “该应用未锁定白名单”
我该如何避免这种行为? 谢谢大家。