How to debug BOOT_COMPLETE broadcast receiver's “Force Close” crashes?

后端 未结 4 1345
广开言路
广开言路 2021-01-30 18:26

Since the phone restarts and thus gets disconnected from the Eclipse debugger/LogCat while it\'s booting up, how do I see where my boot complete broadcast receiver is crashing?<

4条回答
  •  孤城傲影
    2021-01-30 18:59

    As i wrote on another thread:

    You can emulate all broadcast actions by connecting via adb to the device and open a device shell.

    Here we go:

    • open console/terminal and navigating to /platform-tools
    • type "adb shell" or on linux/mac "./adb shell"
    • in the shell type "am broadcast -a android.intent.action.BOOT_COMPLETED" or whatever action you want to fire.

    In this way you should be able to debug.

    There are a bunch of nice commands coming with adb or the adb shell. Just try it

    Regards Flo

    EDIT: Using the above method will also reboot the device. To prevent the device from rebooting use am broadcast -a android.intent.action.BOOT_COMPLETED com.example.app. Note the suffix with the application package name to which the broadcast goes. This enables you to send the BOOT_COMPLETED intent to ONLY YOUR app for debugging purposes. – Roel van Uden

提交回复
热议问题