プッシュ通知、または、ウィジェットのクリック時にPendingIntentを作成し、Activityを起動しています。
起動されたActivityから、更に別のActivityを起動し、戻ると、起動元のActivityが終了してしまいます。
この時、起動元のonActivityResultは呼ばれません。
onDestroyは呼ばれています。
LogCatに例外が出たりもしません(なので、落ちるというよりは、終了している感じ?)。
Intentの作成の仕方が悪いのでしょうか。
(Flagをいろいろ試したりしてみましたがダメでした)
対処法がお分かりになる方いましたらご教授願います(_ _)
以下コード抜粋です。
●PendingIntent発行
NotificationManager notificationManager =
(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new
Notification(R.drawable.statusicon, "アラーム",
System.currentTimeMillis());
Intent notificationIntent = new Intent(context, MainActivity.class);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY |
Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
notification.setLatestEventInfo(context, "テスト", "テスト",
pendingIntent);
notificationManager.notify(R.string.app_name, notification);
●MainActivity、なにかしらのトリガーで別Activity起動
Intent notificationIntent = new Intent(context, SubActivity.class);
startActivityForResult(intent, 1);
●SubActivity
起動後、戻るボタンで戻る
と、MainActivityでは、onActivityResultは呼ばれず、Activityがいきなり終了してしまう。
いちおう。
SDK 2.3.3 を使用しています。
よろしくお願いします。
↓下記をコメントアウト
// notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY |
// Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
↓PendingIntent.FLAG_UPDATE_CURRENTをIntent.FLAG_ACTIVITY_NEW_TASKに変更
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
notificationIntent, Intent.FLAG_ACTIVITY_NEW_TASK);
で実現出来ませんかね?
すごい勘違いなことを言ってたらすんません。
2011年12月13日2:53 gotsun <eil.o...@gmail.com>:
> --
> このメールは Google グループのグループ「Android-SDK-Japan」の登録者に送られています。
> このグループに投稿するには、android-...@googlegroups.com にメールを送信してください。
> このグループから退会するには、android-sdk-ja...@googlegroups.com にメールを送信してください。
> 詳細については、http://groups.google.com/group/android-sdk-japan?hl=ja からこのグループにアクセスしてください。
>
--
Stoic Corp.
CEO Yoshiyuki Kanno
web: http://www.stoic.co.jp/
mailto:yoshiyu...@stoic.co.jp
フラグはあれこれいろいろ試したけどダメだったと、思っていたのですが、、、
気のせいだったのかな。。。
こんなとこも気づかないで恥ずかしいです。。。
ありがとうございました。