Skip to content
This repository has been archived by the owner on Oct 5, 2022. It is now read-only.

LockTaskMode is not set after reboot in complete example #5

Open
AngularPadawan opened this issue Jun 10, 2017 · 3 comments
Open

LockTaskMode is not set after reboot in complete example #5

AngularPadawan opened this issue Jun 10, 2017 · 3 comments

Comments

@AngularPadawan
Copy link

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

@PaulNorton
Copy link

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.

@pourqavam
Copy link

pourqavam commented Jun 2, 2018

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
}

@yurik94
Copy link

yurik94 commented Dec 2, 2020

Happening on a Android 6.0 Alcatel Y with kiosk mode and launcher set.

Anyone have a solution?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants