在特定的时间机器人设置的通知 [英] Set notification at specific time android

查看:138
本文介绍了在特定的时间机器人设置的通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这个问题已经问过,但我在我束手无策这一个。

I realize this question has been asked before, but I'm at my wit's end with this one.

我有一个报警经理建立一个通知:

I have an alarm manager to set up a notification:

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);

}

...然后我通知本身是一个服务:

... And then I have the notification itself that is a service:

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;
    }

}

....我包括烤面包,以确保我实际上是要这个方法。敬酒来了,但通知没有。我在做什么错在这里?它说的是在manifest文件我需要改变吗?

.... I included the toast to make sure that I was actually going to this method. The toast comes up, but the notification does not. What am I doing wrong here? Is it something in the manifest file I need to change?

推荐答案

通知不无图标的工作(或者是它的标题?)。

notifications do not work without an icon (or is it title?).

我敢肯定,我面临同样的问题,在这之前有通知,如果你忽略它,则该通知将显示的内容之一。

I'm sure I faced the same problem before that there's one of the elements of the notification that if you omit it, the notification won't show.

这篇关于在特定的时间机器人设置的通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆