Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Test BOOT_COMPLETED Broadcast Receiver In Emulator

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.

like image 585
Chirag Avatar asked Jul 04 '12 09:07

Chirag


People also ask

Can broadcast receiver run in background?

A broadcast receiver will always get notified of a broadcast, regardless of the status of your application. It doesn't matter if your application is currently running, in the background or not running at all.

What is broadcast receiver in an Android app?

A broadcast receiver (receiver) is an Android component which allows you to register for system or application events. All registered receivers for an event are notified by the Android runtime once this event happens.


1 Answers

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

like image 176
MKJParekh Avatar answered Sep 19 '22 04:09

MKJParekh