我试图让一个,但它有一个缺点是,它在通知抽屉一个空的通知,
public static int when = 0;
private void generateNotification(Context context) {
Log.i(TAG, "generateNotification");
Intent notificationIntent = new Intent(context, MainActivity.class);
PendingIntent pIntent = PendingIntent.getActivity(
this.getApplicationContext(), 0, notificationIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder mNotification = new NotificationCompat.Builder(
this)
// .setContentTitle("AppName")
// .setContentText("Message For Notification Drawer")
// .setSound(soundUri)
// .setDefaults(Notification.DEFAULT_SOUND)
// .setVibrate(new long[] { 1000, 1000 })
// .addAction(R.drawable.ic_launcher, "View", pIntent)
// .addAction(0, "Remind", pIntent)
// .setNumber(fCount)
// .setWhen(when)
.setSmallIcon(R.drawable.ic_launcher)
.setTicker(Integer.toString(when)) // Set String you want
.setAutoCancel(true)
.setContentIntent(pIntent);
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
// notificationManager.notify(when, mNotification.build());
notificationManager.notify(1, mNotification.build());
when++;
}
谢谢您的回答,我已经与此代码完成。检查这个链接>>(http://developer.android.com/guide/topics/ui/notifiers/notifications.html)但它只是更新'Notification Drawer'的内容文本,我想要的是在'通知区域“并持续更新此文本。注意 - 要在“通知区域”中更新,而不是在“通知抽屉”中更新。 – zey 2014-09-29 18:14:48
好吧,但要做到这一点,你必须dinamically与您的文本创建一个图标,然后更新它是实现你想要的东西的唯一方法... – 2014-09-29 18:20:05
正如我在我的问题中提到'setSmallIcon的图像必须在包,没有能力在飞行中编辑它们。不是吗?或者,有没有办法做到这一点? – zey 2014-09-29 18:22:12