Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keep Android debugger alive even after device restart

I am having trouble debugging some code in my DeviceBootReceiver (handles android.intent.action.BOOT_COMPLETED intent). I want to debug this bit, but how does one keep the debugger alive, when the device reboots? Is there any hack that anyone has come across for this?

What I want to do :

  1. Start debugging app via Android Studio
  2. Power down the device
  3. Power up the device
  4. Still be able to get the debugger attached to my app when it starts to handle android.intent.action.BOOT_COMPLETED intent

Any thoughts?

like image 894
Rohitesh Avatar asked Mar 01 '16 06:03

Rohitesh


2 Answers

  1. Open your device "developer options" settings;
  2. Scroll down to "select debug app" and make sure your app is selected there;
  3. Check the option "wait for debugger".

This will make sure that when your app is executed, for example when it receives a BOOT_COMPLETED broadcast, the debugger gets attached first.

Hope it helps.

like image 191
Mr. T Avatar answered Oct 07 '22 15:10

Mr. T


You can re-broadcast the intent by yourself via adb shell:

$ adb shell am broadcast -a android.intent.action.BOOT_COMPLETED

like image 30
Jiyong Park Avatar answered Oct 07 '22 16:10

Jiyong Park