Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug a broadcastreceiver?

With my application i realized a broadcastreceiver fired by a general intent of Android. So the program got no Interface or initial activity. To debug ive selected in the dev tools the "wait for debugger" and it actually works (i can debug the broadcastReceiver). My problem is that dalvik kills my thread (and the whole debug) after few seconds so im unable to check or try step-to-step my procedures. Anybody knows how to solve this?

like image 637
Vash Avatar asked Apr 06 '11 18:04

Vash


Video Answer


2 Answers

You need your BroadcastReceiver to have this in the Manifest:

android:process=":remote"

Put this in your onReceive method:

android.os.Debug.waitForDebugger();

Then run the project. After that click on Attach debugger to Android process and wait for your process to show up (it will have this name: your.package.name:remote) in the window Choose your process, then click OK and start debugging.

enter image description here

like image 188
hiddeneyes02 Avatar answered Sep 20 '22 11:09

hiddeneyes02


In developer options: Select debug app -> your app Wait for debugger

like image 34
kotucz Avatar answered Sep 19 '22 11:09

kotucz