2

通知マネージャー (ステータス バー) でアクティビティを開きたくありません。代わりに、通知がクリックされるとキャンセルされるだけで、何も起こらないはずです。

4

3 に答える 3

4

パスを作成するときはPendingIntent、空のインテントnew Intent()

PendingIntent pending = PendingIntent.getActivity(getApplicationContext(), 0, new Intent(), 0)

通知の FLAG_AUTO_CANCEL フラグを設定します

notification.flags |= Notification.FLAG_AUTO_CANCEL;
于 2012-05-29T07:41:47.193 に答える
4
final NotificationManager notificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
final Notification notification = new Notification(R.drawable.icon,"A New Message!",System.currentTimeMillis());

notification.defaults=Notification.FLAG_ONLY_ALERT_ONCE+Notification.FLAG_AUTO_CANCEL;
Intent notificationIntent = new Intent(this, null);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,notificationIntent, 0);

notification.setLatestEventInfo(AndroidNotifications.this, title,message, pendingIntent);
notificationManager.notify(NOTIFICATION_ID, notification);

クラスをインテントで渡すのではなく、null を渡すか、代わりにインテント() デフォルト コンストラクタを使用します。感謝するのに役立つ場合。

于 2012-05-29T07:46:14.507 に答える
0

finish()から呼び出す空のアクティビティを作成し、onCreate()に設定しPendingIntentます。空(null)のものは許可されていないため、それが最善の策です。

于 2012-05-29T07:41:25.850 に答える