ステータスバー通知からstartActivityForResult()を使用できますか?通知の選択時にstartActivityForResult()を呼び出す
私はアクティビティAを持っています。これは、startActivityForResult()を使用してアクティビティBを開始するイベントがあります。これがバックグラウンドにあるとき、イベントで通知を表示します。今通知を選択すると、結果Bのアクティビティ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
通知に含まれている場合、そのアクティビティは結果を得るでしょうか?その通知は、それが作成したアクティビティに属していないと考えてください。 – kingston
@herschel通知はアクティビティAから作成されるため、アクティビティAがそのonActivityResult()メソッドで結果を取得すると仮定しました。とにかくそれは間違っていますか? – Alabhya
はい私はそれが間違っていると思います。アクティビティAはもう存在しないかもしれません。 – kingston