Ich versuche, eine einzige Zweck-App zu erstellen. Also habe ich eine BaseActivity erstellt, die alle meine Aktivitäten davon erben.Android Studio, Kioskmodus, Einzelgeräte, Lock Task-Modus
es aussehen ist wie
public class LockDeviceActivity erweitert 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();
}
}
so, wenn ich zum ersten Mal die App eingeben, ich einige Fixierte Nachricht sehen und es ist in Ordnung von mir. Das Problem ist, wenn ich eine Absicht von einer Aktivität zur anderen Aktivität zu tun, das Fragment enthält, erhalte ich folgendes Bild:
plus Ich bin einen Toast Nachricht einig Systeme bekommen: "Die App ist nicht für Sperren gesperrt"
Wie kann ich diese Art von Verhalten vermeiden? danke euch allen. Überspringen Konto zurücksetzen