【发布时间】:2014-03-06 20:06:29
【问题描述】:
我尝试了以下 android 通知代码,它运行良好,但是当我启动我的 android 应用程序时它会弹出通知。
我想每 48 小时显示一次通知,我该怎么做?
我需要进行哪些更改才能使其正常工作?
通知代码
Intent notificationIntent = new Intent(MainActivity.this, Activity.class);
PendingIntent contentIntent = PendingIntent.getActivity(MainActivity.this, 0, notificationIntent, 0);
NotificationManager notificationManager = (NotificationManager) MainActivity.this
.getSystemService(Context.NOTIFICATION_SERVICE);
Notification noti = new NotificationCompat.Builder(MainActivity.this)
.setSmallIcon(R.drawable.ic_launcher)
.setTicker("ticker message")
.setWhen(System.currentTimeMillis())
.setContentTitle("HELLO")
.setContentText("PLEASE CHECK WE HAVE UPDATED NEWS")
.setContentIntent(contentIntent)
//At most three action buttons can be added
.setAutoCancel(true).build();
int notifyID =0;
notificationManager.notify(notifyID, noti);
【问题讨论】:
-
@SimplePlan 两个代码都不起作用:(
标签: android android-layout notifications push-notification