Created
June 1, 2015 16:34
-
-
Save Takhion/8495ad44ace53ba8fff7 to your computer and use it in GitHub Desktop.
Task killer for Android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | |
<application> | |
<activity android:name=".TaskKiller"/> | |
</application> | |
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.app.Activity; | |
import android.content.Context; | |
import android.content.Intent; | |
import android.os.Build; | |
import android.os.Bundle; | |
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; | |
import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TASK; | |
import static android.content.Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS; | |
public class TaskKiller extends Activity { | |
public static void killTask(Context context) { | |
final Intent intent = new Intent(context, TaskKillerActivity.class); | |
intent.addFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK | FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); | |
context.startActivity(intent); | |
} | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
if (Build.VERSION.SDK_INT >= 21) finishAndRemoveTask(); | |
else finish(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment