android - why does excludeFromRecents remove all activities? -


my app has 2 entry points (mainactivity , fromnotificationactivity).

i want mainactivity appear in recent tasks, not fromnotificationactivity)

with nothing declared in manifest, if do...

  • mainactivity
  • back
  • fromnotificationactivity
  • back

... find fromnotificationactivity listed in recent tasks

if add android:excludefromrecents="true" fromnotificationactivity in manifest , repeat same sequence, find nothing in recent lists.

what incantations must invoke such after above sequence of steps, mainactivity in recent list.

by default, activities of application have same affinity. activities same affinity conceptually belong same task. hence in case both mainactivity , fromnotificationactivity belong same task. android:excludefromrecents ensures task not listed in recent apps. reason, when android:excludefromrecents set true fromnotificationactivity, mainactivity disappers history.

solution: use android:taskaffinity specify different tasks both activities. use android:excludefromrecents fromnotificationactivity if task should not shown in history @ all.

<activity        android:name="com.example.mainactivity"     android:label="@string/app_name"     android:taskaffinity=".mainactivity" >         <intent-filter>             <action android:name="android.intent.action.main" />             <category android:name="android.intent.category.launcher" />         </intent-filter> </activity>   <activity android:name="com.example.fromnotificationactivity"     android:label="@string/notification_name"     android:taskaffinity=".notificationactivity"     android:excludefromrecents="true">         <intent-filter>             <action android:name="android.intent.action.main" />             <category android:name="android.intent.category.launcher" />         </intent-filter> </activity>  

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -