からブロードキャストを受信するアプリケーションがありますAlarmManager
。これにより、透明なActivity
( AlarmAlertDialogActivity
) が開始され、AlertDialog
. でキャンセルをクリックするとAlertDialog
、 が呼び出されfinish()
ます。
AlarmAlertDialogActivity
は別Activity
の放送受信機から起動されるのではなく、
Intent.FLAG_ACTIVITY_NEW_TASK
これは、アクティビティが新しいタスクで起動されることを意味します。
私の問題は、アプリをキャンセルした後AlertDialog
(つまり、ホーム ボタンを押したままアプリのアイコンをクリックして)、最近の履歴からアプリを再起動すると、AlertDialog が再起動されることです。finish()
/Intent
フラグを使用することで、これを回避できることを期待していました。私がしたいのは、の親アクティビティが起動されるActivity
前の最後です。AlertDialog
Intent.FLAG_ACTIVITY_NO_HISTORY
起動時にビットマスキングを追加フラグとして試しましたAlarmAlertDialogActivity
が、違いはないようです。
ビットマスキングIntent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
は機能しますが、最近の履歴からアプリを削除する必要があります (名前が示すように)。これは、ユーザー エクスペリエンスに悪影響を及ぼします。
それで、私が探しているUIフローを取得することは可能ですか?
更新- 要求された詳細情報:
ブロードキャスト レシーバーからの Logcat、AlertDialog アクティビティ、およびメイン アクティビティ:
05-30 10:36:00.132: D/everyOtherApp(362): Received alarm broadcast at: Wed May 30 10:36:00 GMT+00:00 2012
05-30 10:36:00.262: D/everyOtherApp(362): AlarmAlertDialogActivity.onCreate()
05-30 10:36:00.912: D/everyOtherApp(362): AlarmAlertDialogActivity.onResume()
05-30 10:36:12.461: D/everyOtherApp(362): Cancel pressed
//Cancel exits the activity. I now relaunch the app from recent history:
05-30 10:36:20.233: D/everyOtherApp(362): AlarmAlertDialogActivity.onCreate()
05-30 10:36:21.621: D/everyOtherApp(362): AlarmAlertDialogActivity.onResume()
BroadcastReceiver から Activity を起動するためのコード:
Intent intent = new Intent(new Intent(applicationContext, AlarmAlertDialogActivity.class));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(Constants.SCHEDULED_ALARM_TAG, alarm);
applicationContext.startActivity(intent);
manfest ファイルの AlarmAlertDialogActivity:
<activity
android:name=".AlarmAlertDialogActivity"
android:theme="@android:style/Theme.NoDisplay" >
</activity>