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>