對於某一個應用,如果不想在最近打開的app列表中留下任何紀錄,即按下Home鍵回到主頁,再按任務鍵的時候,任務列表看不到這個app,在AndroidManifest中給Activity標簽添加:android:excludeFromRecents=”true”即可。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.li.test" android:versionCode="1" android:versionName="1.0">
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="23" />
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme">
<activity android:name=".MainActivity" android:excludeFromRecents="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
設置之后,按Home鍵,回到主頁面。點擊任務鍵,顯示“無最近使用的應用程序”。如下圖所示: