manifest:
<receiver android:name=".BatteryFullReceiver" >
<intent-filter>
<action android:name="android.intent.action.BATTERY_OKAY" />
</intent-filter>
</receiver>
Broadcastreceiver:
public class BatteryFullReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
// String intentAction = intent.getAction();
// if(Intent.ACTION_BATTERY_OKAY.equalsIgnoreCase(intentAction)){
Toast.makeText (context, "Battery Full", Toast.LENGTH_LONG).show ();
Speaker.tts.speak("Battery full ,you can disconnect the usb now", TextToSpeech.QUEUE_ADD, null);
}
// }
}
i tried with battery low and that works.but Battery ok is not working. sometimes i used those code that's why i use comment for checking.but nothing is working.please help !!!
You've misspelled the intent action:
android.intent.action.ACTION_BATTERY_OKAY
There's a full example in the docs http://developer.android.com/training/monitoring-device-state/battery-monitoring.html#DetermineChargeState