I need to debug an application that have a BroadcastReceiver that triggers when the device turns on. But Android Studio loses the connection when I turn off the smartphone. How to debug in this case? There's a way to do that?
Asked
Active
Viewed 1,198 times
0
-
For this kind of thing I just use log output to debug. Put something unique in all debug log entries, and grep for that. – Daniel Nugent Jul 05 '16 at 02:25
2 Answers
1
You can simulate a system broadcast using ADB shell's am command in your terminal.
$ adb shell
$ am broadcast -a android.intent.action.BOOT_COMPLETED
Your emulator/device will be rebooted while it still connected with Android Monitor. Note that you cannot simulate Local broadcast, though.

Ken Ratanachai S.
- 3,307
- 34
- 43
0
You can test via
- Emulator, e.g. Genymotion, see How to reboot android device emulator in Genymotion
- Rooted device, using a Hot/Soft reboot (triggered by e.g.
busybox killall system_server
). Most devices stay in contact with the adb server while hot booting.