LockTaskMode is not set after reboot in complete example
I followed step 3 in the tutorial and things worked fine so far. When I rebooted the device from the locked activity, it also correctly boots again into the locked activity.
However, when I check what locked activities are there using adb shell dumpsys activity activities, it is not listed there (it was before the reboot).
When I add a TextInput to LockedActivity and bring up the soft keyboard, it correctly shows only the back button. After the reboot, it shows the home and recents buttons again.
To me, this looks like the Activity fails to enter lockTaskMode after the reboot.
Android 6.0, Kernel version 3.18.19, LenovoPad TB3-X70F
Thanks, Martin
I am experiencing the same issue. Rebooting on a screen in lockTaskMode fails to set it back to lockTaskMode. Found this in the logs:
07-05 15:45:14.583 785 802 V ActivityManager: Broadcast: Intent { act=android.app.action.LOCK_TASK_ENTERING flg=0x10 cmp=com.example.package/.DeviceAdminReceiver (has extras) } ordered=false userid=0 callerApp=ProcessRecord{6438256 785:system/1000}
07-05 15:45:14.584 785 802 V ActivityManager: Broadcast: Intent { act=android.app.action.LOCK_TASK_EXITING flg=0x10 cmp=com.example.package/.DeviceAdminReceiver } ordered=false userid=0 callerApp=ProcessRecord{6438256 785:system/1000}
It looks like it tries to enter lock task mode and immediately exits.
Sorry for late answering, but... Anyone has this problem can do this tricky work in first (LAUNCHER/HOME) activity (e.g. MainActivity):
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (mSharedPreferences.getBoolean(KEY_PREF_RECREATED, false)) {
mSharedPreferences.edit().putBoolean(KEY_PREF_RECREATED, false).apply();
// start LOCK TASK here
} else {
mSharedPreferences.edit().putBoolean(KEY_PREF_RECREATED, true).apply();
finish(); // close the app
startActivity(new Intent(this, MainActivity.class)); // reopen the app
return;
}
setContentView(R.layout.activity_main);
// other codes
}
Happening on a Android 6.0 Alcatel Y with kiosk mode and launcher set.
Anyone have a solution?