Ich kann nicht herausfinden, warum dieser Fehler auftritt. Ich erstelle eine Alarmschaltfläche, die eine Benachrichtigung an den Benutzer VIA sendet.Android Studio Erwartete Klasse oder Paket Fehler
"neue NotificationCompat()" ist, wo mein Fehler ist.
hier ist der 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());
}
}