I want to invoke the onDestroy() callback of an activity through adb command.
Can anyone let me know if there is a way to call finish() of an activity through adb shell command?
I want to invoke the onDestroy() callback of an activity through adb command.
Can anyone let me know if there is a way to call finish() of an activity through adb shell command?
Unless you have overriden onBackPress for that activity,
You can use the back button key event to destroy the activity:
adb shell input keyevent 4
[source][1]
You also have the
adb shell am force-stop "package.name"
and
adb shell am kill "package.name"
But those commands will not trigger onDestroy but kill the process, Plus the am kill only kills processes that are safe to kill (Meaning a process with no running services or activities).
You can finish your app which will close the activity:
adb shell am kill 'your package name'