how to register broadcast receiver for low battery in android?

半腔热情 提交于 2019-12-06 13:49:46

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.

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);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!