WidgetResultActivityとNotificationResultActivityがあり、両方のlaunchmode=singleInstanceを設定します。ただし、動作は異なります。WidgetResultActivityはRECENTから開かれませんが、NotificationResultActivityは常にRECENTから開かれます(単独で開かれます!MainActivityなしで開かれます)。では、Recent、thxからNotificationResultActivityを開くことを禁止するにはどうすればよいですか。
<activity
android:name=".WidgetResultActivity"
android:launchMode="singleInstance"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
<activity
android:name=".NotificationResultActivity"
android:launchMode="singleInstance"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
編集:通知から開いたときに、ATesterアプリを表示してください...
テストコード:
NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.ic_launcher, getString(R.string.app_name), java.lang.System.currentTimeMillis());
notification.flags = Notification.FLAG_NO_CLEAR;
Intent intent = new Intent(this, ExcludeFromRecentActivity.class);
// intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent activity = PendingIntent.getActivity(this, R.string.app_name, intent, PendingIntent.FLAG_UPDATE_CURRENT);
notification.setLatestEventInfo(this, "Open Activity: " + ABox.class.getSimpleName(), "new Intent()", activity);
manager.notify(R.string.app_name, notification);
テストマニフェスト:
<activity
android:name=".ATester1"
android:label="@string/app_name" >
</activity>
<activity
android:name=".ATester2"
android:label="@string/app_name" >
</activity>
<activity
android:name=".ATester3"
android:label="@string/app_name" >
</activity>
<activity
android:name=".ExcludeFromRecentActivity"
android:excludeFromRecents="true"
android:label="@string/app_name" >
</activity>
テスト画像:
1位:
2番目:
3位:
4位:
編集:私が本当に必要としているのは、DIALOG BEHEVIORLIKEACTIVITYです。別の投稿で質問します。@ WebnetMobile.com、すべて同じようにありがとう。