Last active
December 19, 2015 10:53
-
-
Save baleen37/02decb17b96c42898173 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| public final class KillReceiver extends BroadcastReceiver { | |
| private Activity activity; | |
| public static final String ACTION_KILL_ACTIVITY = "ACTION_KILL_ACTIVITY"; | |
| public KillReceiver(Activity activity) { | |
| this.activity = activity; | |
| if(activity == null) throw new NullPointException("activity == null"); | |
| } | |
| @Override | |
| public void onReceive(Context context, Intent intent) { | |
| activity.finish(); | |
| } | |
| public static Intent createIntent(Context context) { | |
| return new Intent(context.getPackageName() + "." + ACTION_KILL_ACTIVITY); | |
| } | |
| public KillReceiver register() { | |
| activity.registerReceiver(this, new IntentFilter(activity.getPackageName() + "." + ACTION_KILL_ACTIVITY)); | |
| return this; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment