通知がクリックされたときにListItem
をハイライトしたいと思います。 ListView
と表示されている私の活動は既に開いているので、通知をクリックすると再び開くことができません。私は多くを検索しましたが、私は通知のための方法はないと思っています。onClick()
だからどうすればいいのか教えてください。通知のためのonClick()リスナー
これは、私はあなたがあなたの保留中の意図に余分を置くことができ、通知
Intent intent = new Intent();
PendingIntent pIntent = PendingIntent.getActivity(context, notification_id, intent, 0);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context);
mBuilder.setTicker("Smart Locator");
mBuilder.setSmallIcon(R.drawable.notification_icon);
mBuilder.setContentTitle(name);
DetailsContainer dc = new LocationDetails(context).getDetails(location);
mBuilder.setContentText(date + ", " + dc.area + " " + dc.locality);
mBuilder.setContentIntent(pIntent).getNotification();
mBuilder.setAutoCancel(true);
mBuilder.getNotification().flags |= Notification.FLAG_AUTO_CANCEL;
Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
mBuilder.setSound(alarmSound);
NotificationManager mNotificationManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(document_id, notification_id, mBuilder.build());
:
そして、あなたの活動に次のコードを使用しますどのアクティビティでそれを処理できますか。そこから、クリックした通知の種類と、選択したいListViewデータの位置を知るためのデータが必要です –
[通知のためにクリックリスナーを設定する方法は?](http://stackoverflow.com/質問/ 7184963 /通知設定のための設定方法) –