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

后端 未结 4 1344
广开言路
广开言路 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:56

    Just put to your terminal in Android Studio

    adb shell am broadcast -a android.intent.action.BOOT_COMPLETE

    0 讨论(0)
  • 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

    0 讨论(0)
  • 2021-01-30 19:09

    check your Intent's actions and bundles you are recieving ,they may null and can be a null pointer exception.

    0 讨论(0)
  • 2021-01-30 19:22

    The receiver is only controlling when your code runs (i.e when the phone starts). Whilst debugging, run the code manually. You can resolve 99% of your issues this way and the remaining ones (if any) you can resolve by writing to LogCat so see what your code is doing.

    0 讨论(0)
提交回复
热议问题