ステータスバー通知から startActivityForResult() を使用することは可能ですか?
あるイベントで startActivityForResult() を使用してアクティビティ B を開始するアクティビティ A があるとします。バックグラウンドでイベントが発生すると、通知が表示されるようになりました。通知を選択すると、結果のアクティビティ B を開始するにはどうすればよいですか?
アクティビティ A にはバックグラウンドで実行されるサービスが必要であることは理解していますが、その場合でも同じ質問が当てはまると思います。
通知のコードは次のとおりです。これはアクティビティ A にあります。
Notification notification = new Notification(R.drawable.ic_launcher, "New Notification", System.currentTimeMillis());
notification.flags = Notification.FLAG_AUTO_CANCEL;
CharSequence contentTitle = "My Notification Title";
CharSequence contentText = "My Notification Text";
Intent notificationIntent = new Intent(this, ActivityB.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.setLatestEventInfo(getApplicationContext(), contentTitle, contentText, contentIntent);
nm.notify(1, notification); //1 = id