【发布时间】:2014-02-24 07:20:46
【问题描述】:
我正在使用以下代码将图标添加到通知状态,效果很好,即使我退出应用程序也始终显示。
但是重启手机后图标消失了,怎么才能让手机重启后图标一直显示呢?
private void showNotification() {
NotificationManager notificationManager = (NotificationManager)
this.getSystemService(android.content.Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.smsforward,"My System", System.currentTimeMillis());
notification.flags |= Notification.FLAG_ONGOING_EVENT;
notification.flags |= Notification.FLAG_NO_CLEAR;
CharSequence contentTitle = "My System Title";
CharSequence contentText = "My System Title content";
Intent notificationIntent = new Intent(this, SMSMain.class);
PendingIntent contentItent = PendingIntent.getActivity(this, 0,
notificationIntent, 0);
notification.setLatestEventInfo(this, contentTitle, contentText,contentItent);
notificationManager.notify(0, notification);
}
【问题讨论】:
标签: android