我正在使用以下代碼將圖標添加到通知狀態,它運行良好,即使我退出應用程序,它也會始終顯示。重新啓動手機後,如何始終顯示通知圖標?
但是,只要我重新啓動手機,圖標就會消失,即使重新啓動手機,圖標也會始終顯示,我該怎麼做?
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);
}
謝謝!在我的mainifest文件中,我有代碼<! - Broadcast receiver - > intent-filter> ,我可以添加一個新的? –
HelloCW
當然。您可以根據需要添加儘可能多的廣播接收器。 – Adnan