I am having the exact same problem as this post: Battery broadcast receiver doesn't work. But it seems no one has answered that question.
Here is my BroadcastReceiver:
public class BatteryLevelReceiver extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
Log.v("plugg", "plug change fired");
Toast.makeText(context, " plug change fired", Toast.LENGTH_LONG).show();
}
And here is my AndroidManifest.xml:
<receiver android:name=".ReceversAndServices.BatteryLevelReceiver">
<intent-filter android:priority="900">
<action android:name="android.intent.action.BATTERY_LOW" />
</intent-filter>
</receiver>
<receiver android:name=".ReceversAndServices.BatteryLevelReceiver">
<intent-filter android:priority="900">
<action android:name="android.intent.action.BATTERY_CHANGED" />
</intent-filter>
</receiver>
I have also added this line to the manifest:
<uses-permission android:name="android.permission.BATTERY_STATS"/>
But still no success!
I would really appreciate if someone could advise me what I am doing wrong.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…