reboot emulator, broadcast boot complete event

You can use the following command from adb:

adb shell am activity/service/broadcast -a ACTION -c CATEGORY -n NAME

for example:

adb shell am broadcast -a android.intent.action.BOOT_COMPLETED -c android.intent.category.HOME -n package_name/class_name

Note that class name and package names need to be as defined in the Manifest.

This will generate the Intent you want , directed only to the component you want (otherwise you system will go crazy with BOOT_COMPLETED sent...)

扫描二维码关注公众号,回复: 578535 查看本文章

 =================================================================================

To emulate a broadcast action, you can connect via adb to the emulator/device and open a shell:

adb shell

Then, you can broadcast the action you want to test:

am broadcast -a android.intent.action.BOOT_COMPLETED

Please note that, in the latest Android versions, broadcasting the *android.intent.action.BOOT_COMPLETED* action will actually reboot your emulator/device.

猜你喜欢

转载自hooroger.iteye.com/blog/2067334