我意识到这个问题以前已经被问过了,但是我在这个机智的结尾.
public void to_reminder(View view) { Intent intent=new Intent(this,Notification_morning.class); AlarmManager manager=(AlarmManager)getSystemService(Activity.ALARM_SERVICE); PendingIntent pendingIntent=PendingIntent.getService(this,intent,0); Calendar cal=Calendar.getInstance(); cal.set(Calendar.HOUR_OF_DAY,timepicker.getCurrentHour()); cal.set(Calendar.MINUTE,timepicker.getCurrentMinute()); cal.set(Calendar.SECOND,0); cal.set(Calendar.MILLISECOND,0); manager.setRepeating(AlarmManager.RTC_WAKEUP,cal.getTimeInMillis(),24*60*60*1000,pendingIntent); }
public class Notification_morning extends Service { @Override public void onCreate() { Toast.makeText(this,"MyAlarmService.onCreate()",Toast.LENGTH_LONG).show(); Intent resultIntent=new Intent(this,Calendar_start.class); PendingIntent pIntent=PendingIntent.getActivity(this,resultIntent,0); Notification noti_builder= new Notification.Builder(this) .setContentTitle("Don't forget to plan your activitites for the day! ") .setContentIntent(pIntent) .build(); notificationmanager notificationmanager = (notificationmanager) getSystemService(NOTIFICATION_SERVICE); //what does this do!? noti_builder.flags |=Notification.FLAG_AUTO_CANCEL; notificationmanager.notify(1,noti_builder); } @Override public IBinder onBind(Intent intent) { return null; }
}
….我包括烤面包,以确保我实际上是去这个方法.烤面包起来,但通知没有.我在这里做错了什么?是否需要更改清单文件中的内容?
解决方法
原文地址:https://www.jb51.cc/android/124781.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。