I have added a some itent like AACTION_POWER_CONNECTED in my manifest file, I want to get Notification when charger is connected. This my code.
public class AwesomeReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(context, "Inside onReceive", Toast.LENGTH_LONG).show();
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context);
mBuilder.setSmallIcon(R.drawable.ic_launcher);
mBuilder.setContentTitle("This is A Notification");
mBuilder.build();
}
}
I am getting the Toast
each time when I connect my charger but not getting the notification. As I am completely new in Android, I don't know how to achieve this.