java设置特定时间_java – 在特定时间设置通知android

我意识到这个问题以前已经被问过了,但是我在这个机智的结尾.

我有一个报警管理员设置通知:

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,

0,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,0,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;

}

}

….我包括烤面包,以确保我实际上是去这个方法.烤面包起来,但通知没有.我在这里做错了什么?是否需要更改清单文件中的内容?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值