I want to check the BROADCAST RECEIVER
with Action BOOT_COMPLETED
in the emulator
.
Is there any way to check that broadcast receiver in emulator ? How can i restart emulator to check that receiver ? is there any direct command?
Thanks in advance.
There is no Power Button in Emulator like Devices have,So
To stop an emulator instance, just close the emulator's window.
And To Start/Restart
it Start from AVD Manager of Eclipse and Your BroadcastReceiver with BOOT_COMPLETE action will get called for sure
You can start AVD another way also, From CMD
go to Tools of AndroidSDK and give this commmand E:\android-sdk-windows\tools>emulator -avd AVDNAMEHERE
To Send Broadcast from CMD you can use this Command.
adb shell am broadcast -a android.intent.action.BOOT_COMPLETED -c
android.intent.category.HOME -n package_name/class_name
Read more about Android Emulator : Android Emulator and Using Emulator
Basically this is what you have to do to Emulate the Boot Complete in Android Emulater while is is running:Assuming you are a Windows User.The same applies for Linux
STEPS:On your Console type
adb shell
am broadcast -a android.intent.action.BOOT_COMPLETED
That is all folks. see the diagram below for a detailed illustration.
Happy Coding!
Some apps may misbehave if BOOT_COMPLETED is received twice, instead limit broadcast to your package only:
adb shell am broadcast -a android.intent.action.BOOT_COMPLETED -p com.example.package
If you're using flavors, be careful with the .
component name shortcut notation.
Example
adb shell am broadcast -a android.intent.action.BOOT_COMPLETED -n com.companyname.develop/com.companyname.notification.RescheduleLocalNotificationsAtBootReceiver
To restart the emulator just open your command line and switch to folder where your adb is (if not in system path) and enter:
adb restart
(then you can abort the command with Strg - C to get cmd line back)