Skip to content

Instantly share code, notes, and snippets.

@easterapps
Last active March 23, 2024 18:44
Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save easterapps/7127ce0749cfce2edf083e55b6eecec5 to your computer and use it in GitHub Desktop.
Save easterapps/7127ce0749cfce2edf083e55b6eecec5 to your computer and use it in GitHub Desktop.
restart android application programmatically
fun triggerRestart(context: Activity) {
val intent = Intent(context, MainActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
context.startActivity(intent)
if (context is Activity) {
(context as Activity).finish()
}
Runtime.getRuntime().exit(0)
}
@Omar-D
Copy link

Omar-D commented Jul 31, 2023

@easterapps thank you very much it works like a charm on all devices ❤️

@tkkcc
Copy link

tkkcc commented Sep 2, 2023

awesome, help me solve memory leak of DexClassLoader

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment