Skip to content

Instantly share code, notes, and snippets.

@kiwipxl
Created December 12, 2017 23:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kiwipxl/a33874b7d2ee06a847035d9bcaab19fb to your computer and use it in GitHub Desktop.
Save kiwipxl/a33874b7d2ee06a847035d9bcaab19fb to your computer and use it in GitHub Desktop.
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