I cannot figure out why this error is occurring. I am creating an alert button that sends a notification to the user VIA vibrate.
"new NotificationCompat()" is where my error is.
here is the code:
public class AlertReceiver extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
createNotification(context, "It Is Time To Stand Up!","20 Minutes Have Passed", "Alert");
}
public void createNotification(Context context, String msg, String msgText, String msgAlert ) {
PendingIntent notificIntent = PendingIntent.getActivity(context,0,new Intent(context,CustomizeAlertsPage.class),0);
NotificationCompat.Builder mBuilder = new NotificationCompat().Builder(context)
.setLargeIcon(R.drawable.ALERT)
.setContentTitle(msg)
.setTicker(msgAlert)
.setContentText(msgText);
mBuilder.setContentIntent(notificIntent);
mBuilder.setDefaults(NotificationCompat.DEFAULT_VIBRATE);
mBuilder.setAutoCancel(true);
NotificationManager mNotificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(1,mBuilder.build());
}
}
Change
NotificationCompat.Builder mBuilder = new NotificationCompat().Builder(context)
to
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With