ExcludeFromRecents activity not working on Android 5.0

I try to finish the activity and not have it in the responses. The following code seems to work on KitKat, but not on lolipop, since activity is always displayed in the responses.

intentInvite = new Intent( context, OnInviteActivity.class ); intentInvite.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intentInvite.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intentInvite = createInviteIntent( intentCloud, intentInvite ); context.startActivity( intentInvite ); 

AndroidManifest.xml

 <activity android:name=".OnInviteActivity" android:label="@string/app_name" android:excludeFromRecents="true" android:noHistory="true" 
+6
source share
4 answers

Try adding a unique Affinity task:

 <activity android:name=".OnInviteActivity" android:label="@string/app_name" android:taskAffinity=".OnInviteActivity" android:excludeFromRecents="true" android:noHistory="true" 
+3
source

This is a known issue in Android 5.0 since the preview of L. Google seems to be working on this.

Below are the open issues for the same

+3
source

fooobar.com/questions/980109 / ... is a well-known issue with Android.

This can be done programmatically.

 ActivityManager am =(ActivityManager)getSystemService(Context.ACTIVITY_SERVICE); if(am != null) { List<ActivityManager.AppTask> tasks = am.getAppTasks(); if (tasks != null && tasks.size() > 0) { tasks.get(0).setExcludeFromRecents(true); } } 

If the task "Main task" is excluded from recent times, all actions in this task will also be excluded.

+1
source

I had the same issue with android Jelly Bean and I had this in my manifest:

 <activity android:name=".MainActivity" android:label="@string/app_name" android:excludeFromRecents="true" android:noHistory="true" /> 

I removed android:noHistory="true" and it worked, recent applications have stopped showing my activity. It seems that noHistory and execludeFromRecents are not compatible for some reason.

0
source

Source: https://habr.com/ru/post/980109/


All Articles