在特定的时间机器人设置的通知机器人、通知、时间、在特定

由网友(挽青丝)分享简介:我知道这个问题已经问过,但我在我束手无策这一个。 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...

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

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.

阅读全文

相关推荐

最新文章