-3

I need to write an android application that detects following broadcast receivers and displays them in a dialogue box, which goes away when user clicks the box. 1. Power Connected 2. Power Disconnected 3. Battery Low 4. Battery Okay 5. Ringer Mode Changed 6. WiFi State Changed

How can it be done?

Aman Verma
  • 319
  • 1
  • 3
  • 4

2 Answers2

0

There are system wide intents to get the app notified when some hardware events occur. For example, for Battery check out http://developer.android.com/training/monitoring-device-state/battery-monitoring.html http://stackoverflow.com/questions/13228849/how-to-detect-when-the-batterys-low-android

Also for other events, search for intents and register them in android manifest and register a receiver. Should be simple.

Panther
  • 8,938
  • 3
  • 23
  • 34
0

Each of your app behaviors needs related system action name inside. However, you can put them into one receiver into xml registration and make your receiver class as a functional monitor, such as:

<receiver android:name=".myReceiver"> <intent-filter> <action android:name="android.intent.action.ACTION_POWER_CONNECTED"/> <action android:name="android.intent.action.ACTION_POWER_DISCONNECTED"/> <action android:name="android.intent.action.ACTION_BATTERY_LOW"/> <action android:name="android.intent.action.ACTION_BATTERY_OKAY"/> <action android:name="android.media.RINGER_MODE_CHANGED"/> <action android:name="android.net.wifi.WIFI_STATE_CHANGED"/> </intent-filter> </receiver>

Field.D
  • 158
  • 1
  • 1
  • 9