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?
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.
In developer options: Select debug app -> your app Wait for debugger
Put your stuff in another thread:
public void onReceive(final Context context, Intent intent) {
new Thread(new Runnable(){
@Override
public void run() {
Log.i("foo","set me as line breakpoint.");
}
}).start();
}
精彩评论