Created
December 12, 2017 23:35
-
-
Save kiwipxl/a33874b7d2ee06a847035d9bcaab19fb to your computer and use it in GitHub Desktop.
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
public class Extensions | |
{ | |
private Context context; | |
public Extensions(Context context) | |
{ | |
this.context = context; | |
} | |
public void RestartApp() | |
{ | |
Intent mStartActivity = new Intent(context, context.getClass()); | |
int mPendingIntentId = 123456; | |
PendingIntent mPendingIntent = PendingIntent.getActivity(context, mPendingIntentId, mStartActivity, | |
PendingIntent.FLAG_CANCEL_CURRENT); | |
AlarmManager mgr = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE); | |
mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, mPendingIntent); | |
System.exit(0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment