2012-10-23 108 views
1

我從notifiation開始臨時活動,只顯示一些文本消息。無論我設置launchMode = singleInstance還是noHistory = true,從「Recent open」輸入時,上次顯示的臨時活動將再次顯示。我只希望在單擊通知時顯示臨時活動,但不要在「最近打開」中顯示。先謝謝你。Android LaunchMode不起作用

<activity 
     android:name=".NotifiticationDialog" 
     android:launchMode="singleInstance" 
     android:noHistory="true" 
     android:theme="@android:style/Theme.Translucent.NoTitleBar" > 


      Notification notification = new Notification(R.drawable.icon, context.getString(R.string.app_name), System.currentTimeMillis()); 
      Intent intent = new Intent(context, NotifiticationDialog.class); 
      intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); 
      PendingIntent activity = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); 
      notifycation.setLatestEventInfo(context, context.getString(R.string.app_name), message, activity); 
      notifycation.flags = Notification.FLAG_AUTO_CANCEL; 
      _nm.notify(NotifiticationDialog.ID, text); 

編輯: @Lalit Poptani,我想你有什麼建議,但它不是啥子我需要的。當我點擊與android:excludeFromRecents =「true」的臨時活動後,我的應用程序消失在「最近」(用戶找不到它,我的所有活動被排除)

編輯: 事實:我有3 tmp活動顯示一些文本就像烤麪包一樣,有2個從小部件打開,他們沒有與應用程序堆棧混合。 1是從通知開始操作,它總是從「最近」單獨顯示。

<activity 
     android:name=".AppwidgetDialog1" 
     android:launchMode="singleInstance" 
     android:noHistory="true" 
     android:theme="@android:style/Theme.Translucent.NoTitleBar" /> 
    <activity 
     android:name=".AppwidgetDialog2" 
     android:launchMode="singleInstance" 
     android:noHistory="true" 
     android:theme="@android:style/Theme.Translucent.NoTitleBar" /> 
    <activity 
     android:name=".NotifiticationDialog" 
     android:excludeFromRecents="true" 
     android:theme="@android:style/Theme.Translucent.NoTitleBar" > 

+1

解決! http://stackoverflow.com/questions/13026554/launchmode-recent-app-principle – thecr0w

回答

1

對於從最近訪問的應用刪除您的活動,你可以使用android:excludeFromRecents,所以儘量增加android:excludeFromRecents="true"你的活動標籤。

+0

沒有SingleInstance需要? – thecr0w

+0

不,'singleInstance'和'noHistory'是與Activity Stack相關的主題,而不是'recent apps'歷史。 –

+0

不是我想要的,看看我上面的編輯。 – thecr0w