how to register broadcast receiver for low battery

2019-05-28 17:44发布

I want to register broadcast for low battery. If battery status reached at some level I want to get alert...

Please if you have any idea please help me..

2条回答
可以哭但决不认输i
2楼-- · 2019-05-28 18:04

You will need to register a BroadcastReceiver for ACTION_BATTERY_LOW. You can do this in the manifest with a <receiver> element or via registerReceiver() from some already-running component of your application.

查看更多
再贱就再见
3楼-- · 2019-05-28 18:04

For Battery_Status_Low, You could try registering it through a Service for example, like:

BatteryReceiver receiver = new BatteryReceiver(); 
IntentFilter inf = new IntentFilter();
inf.addAction("android.intent.action.BATTERY_LOW");`
registerReceiver(receiver, inf);
查看更多
登录 后发表回答