0

追跡のようなタイマーで通知を設定しましたが、20秒ごとに繰り返すだけです.

最初の反復中に通知が表示され、ログには 20 秒ごとにコードを通過することが示されますが、初回以降は通知が電話に表示されません。理由がわからない、何か考えはありますか?

NotificationManager notificationManager = (NotificationManager)getBaseContext().getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.ic_launcher, "App is running on this Phone. ", 1);

String title = "App";

Intent notificationIntent = new Intent(getBaseContext(), MyActivity.class);
// set intent so it does not start a new activity  
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);

PendingIntent intent2 = PendingIntent.getActivity(getBaseContext(), 0,notificationIntent, 0);

notification.setLatestEventInfo(getBaseContext(), title, "App is running on this Phone. ", intent2);
//notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.flags |= Notification.FLAG_ONGOING_EVENT;

notificationManager.notify(0, notification);

Log.e("APP_DEBUG: doNotify finished", "APP_DEBUG: doNotify finished");
4

0 に答える 0