[This object is not implemented due to a problem with the version
([由于版本问题,此对象未实现)
NotificationCompat.Builder builder = new NotificationCompat.Builder (context)
How can I solve it in android studio ?
(如何在android studio中解决?)
] (])
my code : in home activity
(我的代码:在家庭活动中)
''' public void alarm() {
('''公共无效警报(){)
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, 10);
calendar.set(Calendar.MINUTE, 16);
calendar.set(Calendar.SECOND, 0);
Intent alertIntent = new Intent(getApplicationContext(), AlertReceiver.class);
AlarmManager alarmManager = (AlarmManager) getSystemService( ALARM_SERVICE );
alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), PendingIntent.getBroadcast(getApplicationContext(), 0, alertIntent,
PendingIntent.FLAG_UPDATE_CURRENT ));
}
'''
(''')
public class AlertReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
PendingIntent notification = PendingIntent.getActivity(context, 0, new Intent(context, MainActivity.class), 0);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.ic_notifications_active_black_24dp)
.setContentTitle("CURA here
")
.setContentText("Do you feel good :), if not :(, I can help you ^_^");
builder.setContentIntent(notification);
builder.setDefaults(NotificationCompat.DEFAULT_SOUND);
builder.setAutoCancel(true);
NotificationManager mm =( NotificationManager ) context.getSystemService(Context.NOTIFICATION_SERVICE);
mm.cancel(1);
mm.notify(1, builder.build());
}
}
Image attachment to illustrate problem
(图片附件说明问题)
ask by LaiLa AlQam translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…