Start debugging Android application right after re

2019-05-16 08:09发布

问题:

Helo !

I am working right now with an application that uses BOOT_COMPLETED receiver.

So if I want to debug this application with some breakpoints in its class, I have to reboot my phone and connect to it in the proper time, but I am always too late.

Have you got any better solutions how to debug my application exact when it starts its lifetime with device reboot case ?

Thanks !

回答1:

You can wait for a debugger - Debug.waitForDebugger()



回答2:

Close your emulator and Run the application directly in Debug and select the option to launch the emulator that you want to run it on.



回答3:

It's an strange thing, but, what if you put a 20 sec pause or loop before your first break point?



回答4:

In this case logging is better solution than debuggung. I was able to see logs arising from BOOT_COMPLETE processing even in IDEA logcat window. (I also do not value step by step debugging very much, and prefer TDD approach anyway)