0

I have a broadcastreceiver that should make a toast when battery changed.
The broadcast is through the manifest file and a class.
From some Reason it doesnt working as should.

Broadcast class :

public class BroadcastBattery extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        int battery = intent.getIntExtra("level",0);
        Toast.makeText(context,battery+ "%",Toast.LENGTH_LONG).show();
    }
}

manifest (only the relevant part):

<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<application
        <receiver android:name=".BroadcastBattery">
            <intent-filter android:priority="100">
                <action android:name="android.intent.action.BATTERY_CHANGED" />
            </intent-filter>
        </receiver>
</application>
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Tal Malka
  • 13
  • 4
  • https://stackoverflow.com/a/11277524 – Mike M. Apr 09 '20 at 17:21
  • 3
    Does this answer your question? [I can't receive broadcast on battery state change?](https://stackoverflow.com/questions/11277302/i-cant-receive-broadcast-on-battery-state-change) – bartonstanley Apr 09 '20 at 23:52

0 Answers0