Skip to content

Instantly share code, notes, and snippets.

@easterapps
Last active December 16, 2025 19:28
Show Gist options
  • Select an option

  • Save easterapps/7127ce0749cfce2edf083e55b6eecec5 to your computer and use it in GitHub Desktop.

Select an option

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

Omar-D commented Jul 31, 2023

Copy link
Copy Markdown

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

@tkkcc

tkkcc commented Sep 2, 2023

Copy link
Copy Markdown

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