-
-
Save vargasgabriel/c395da1566904f7d338e48ea9dff12f1 to your computer and use it in GitHub Desktop.
restart android application programmatically
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
| 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) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment