私はカスタム通知を作成しています。インテントのレシーバーで、通知自体のレイアウトの要素のテキストを変更します。通知を更新しても何も起こりません。インテントがレシーバーに渡されています。ログを確認しました。通知を行うアクティビティと受信者は別のクラスです。何か案は?ウィジェットの AppWidgetProvider がうまく機能することはわかっていますが、この場合、AppWidgetProvider はありません。これは単純な通知です。RemoteView を無効にする他の方法はありますか?
//Receiver.onReceive() method
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.notification_layout);
//make dataString
views.setTextViewText(R.id.n_track_name, dataString);
//while searching i figured out this is something that should update notification
NotificationManager mNotificationManager = (NotificationManager)act.getSystemService(Activity.NOTIFICATION_SERVICE);
mNotificationManager.notify(1, act.notification);
これは、他のアクティビティで初めて通知を行うコードです。
Notification notification = new Notification(icon, "Music Player", when);
NotificationManager mNotificationManager = (NotificationManager)MusicPlayerActivity.currentActivity.getSystemService(NOTIFICATION_SERVICE);
RemoteViews contentView = new RemoteViews(act.getPackageName(), R.layout.notification_layout);
//make pending intent on button
Intent intent = new Intent(act, NotificationReceiver.class);
intent.setAction(NotificationReceiver.ACTION_NOTIFICATION_NEXT);
PendingIntent actionPendingIntent = PendingIntent.getBroadcast(act, 0, intent, 0);
contentView.setOnClickPendingIntent(R.id.n_btnNext, actionPendingIntent);
//make other intents
//show notification
mNotificationManager.notify(1, notification);