I am searching from 3 last Days that
How to remove activity from recent list (also known as overview screen, recent app list..etc)
Here is the my android manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.abc.visibility">
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:noHistory="true"
android:taskAffinity=""
android:excludeFromRecents="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Here is the my JavaCode for MainActivity
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
protected void onResume() {super.onResume();}
public void onWindowFocusChanged(boolean hasFocus) {if (!hasFocus) {clearTask();}}
void clearTask(){if(android.os.Build.VERSION.SDK_INT >= 21){finishAndRemoveTask();} else{finish();}}
@Override
public void onBackPressed() {super.onBackPressed();}
}
So, my question is the simple.....
How to remove my activity from recent list
In my Case : Only one activity
- Activity needs to started.
- Once user click on Recent button (Android standard button)
- it need to finish and needs not show in recent list
I need this much only.
Help me friends if you really know how to do it....