To be able to reload/debug an app in Android Studio I always have to kill the app manually via Recent screens, otherwise I get "Couldn't terminate the existing process for myapp".
Now I made the app optionally as home app - when the app starts, it switches to kiosk mode (lockTask()
, it is a device owner) and sets itself as home activity (via DevicePolicyManager.addPersistentPreferredActivity()
) so that the app starts at boot as soon as possible. The app has a password-locked way to leave the kiosk mode (stopLockTask()
) which also restores the original home-activity (via DevicePolicyManager.clearPackagePersistentPreferredActivities()
). However, the app stays running, and being a former home app, it is not listed in "Recent screens". Therefore, it cannot be killed, only via adb root + adb kill.
But my HW tablet (unlike the android emulator) has no adb root, I cannot kill the app there. It cannot be restarted by Android Studio for debugging then.
Please is there a way to kill/stop an app via android UI which was formerly a home app and thus is not listed in "Recent screens"?
To be able to reload/debug an app in Android Studio I always have to kill the app manually via Recent screens, otherwise I get "Couldn't terminate the existing process for myapp".
Now I made the app optionally as home app - when the app starts, it switches to kiosk mode (lockTask()
, it is a device owner) and sets itself as home activity (via DevicePolicyManager.addPersistentPreferredActivity()
) so that the app starts at boot as soon as possible. The app has a password-locked way to leave the kiosk mode (stopLockTask()
) which also restores the original home-activity (via DevicePolicyManager.clearPackagePersistentPreferredActivities()
). However, the app stays running, and being a former home app, it is not listed in "Recent screens". Therefore, it cannot be killed, only via adb root + adb kill.
But my HW tablet (unlike the android emulator) has no adb root, I cannot kill the app there. It cannot be restarted by Android Studio for debugging then.
Please is there a way to kill/stop an app via android UI which was formerly a home app and thus is not listed in "Recent screens"?
Share Improve this question asked Feb 7 at 12:47 Pavel HofmanPavel Hofman 131 gold badge1 silver badge6 bronze badges1 Answer
Reset to default 0while your device may not be rooted you can still do stuff via adb from the command line.
Since you say your app is the device owner (assuming your are using a debug build) you need to remove it as device owner each time you want to debug a new build from android studio.
you would do the command
adb shell dpm remove-active-admin com.my.package/.MyAdminReceiver
to remove it as device admin. Then you would run it again from android studio and set it back to device owner with.
adb shell dpm set-device-owner com.my.package/.MyAdminReceiver
you can also use android studio to attach to a current process for debugging too