Application should not display in recent app list after finish the activity if app was not displaying recent app list previously

前端 未结 3 1126
时光说笑
时光说笑 2021-01-12 12:34

Step 1- Application is not exist in recent app list (App has been removed from recent app list).
Step 2- As soon as I got notification open IncomingCall activity, User a

相关标签:
3条回答
  • 2021-01-12 13:00

    Add

    android:excludeFromRecents="true" 
    

    to the activity tag of your launcher activity in AndroidManifest.xml file

    <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:excludeFromRecents="true">
    ....
    </activity>
    
    0 讨论(0)
  • 2021-01-12 13:02

    Thanks God, I got answer after wondering a week. Add singleInstance attribute along with exclude from recent. It was a bug in 5.0 now has been resolved in 5.1

     <activity
            android:name="activityName"
            android:excludeFromRecents="true"
            android:launchMode="singleInstance"
             >
     </activity>
    
    0 讨论(0)
  • 2021-01-12 13:04

    As per you needs, finishAndRemoveTask() is the new API that as per the documentation

    Finishes all activities in this task and removes it from the recent tasks list.

    if(android.os.Build.VERSION.SDK_INT >= 21)
    {
        finishAndRemoveTask();
    }
    else
    {
        finish();
    }
    
    0 讨论(0)
提交回复
热议问题