Android adb shell am broadcast: Bad component name

落花浮王杯 提交于 2019-11-28 04:05:57
lapis

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 :)

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.

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

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" />

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!