Friday, January 10, 2014

Sending Android BOOT_COMPLETED broadcast using adb

It's easy to broadcast an intent to a specific application using adb. For example, if you want your app to run automatically after system is up, you'd want to catch BOOT_COMPLETED intent like this in your manifest:

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

After all those related coding, you can use this to test if everything is set up correctly:

adb shell am broadcast -a android.intent.action.BOOT_COMPLETED -n urdomain.appname/.classname
Note that the classname is the BroadcastReceiver which receives the "android.intent.action.BOOT_COMPLETED" intent. Broadcasting is carried out successfully if you see:
Broadcasting: Intent { act=android.intent.action.BOOT_COMPLETED cmp=com.nvidia.cms/.AutoStart } Broadcast completed: result=0

No comments:

Post a Comment