Android adb shell am broadcast: Bad component name

后端 未结 4 1286
说谎
说谎 2020-12-07 20:32

I am trying to \'emulate\' a reboot (or anything else with the adb shell am) and am unable to figure out how to reference my component. Then again, maybe I don

相关标签:
4条回答
  • 2020-12-07 20:58

    Try

    adb shell am broadcast \ -a android.intent.action.BOOT_COMPLETED \ -n net.fstab.checkit_android/.StartupReceiver

    (note the -n net.fstab.checkit_android/.StartupReceiver) to aim at a specific receiver.

    Also make sure your app uses permission to receive specific broadcast intents - in this case it would be

    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

    0 讨论(0)
  • 2020-12-07 21:03

    You need to specify the package name before the class name (then you may write it without the package) like this:

    ./adb shell am broadcast -a android.intent.action.BOOT_COMPLETED -c android.intent.category.HOME -n net.fstab.checkit_android/.StartupReceiver
    

    Practically it turns out that you just have to add a slash after the package name.

    You helped me start, I helped you finish :)

    0 讨论(0)
  • 2020-12-07 21:05

    Broadcast does not require specify any Receiver. This case, please just stroke

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

    Hope this help.

    0 讨论(0)
  • 2020-12-07 21:08

    Some apps may misbehave if BOOT_COMPLETED is received twice, instead limit broadcast to your app only:

    adb shell am broadcast -a android.intent.action.BOOT_COMPLETED -p com.example.package
    
    0 讨论(0)
提交回复
热议问题