Reputation: 173
At the end of my application , i have a button to restart the application..
What is the way to restart an application in the onClick Listener of a button??
I tried doing it by creating an intent with "com.android.action.main"
But it doesnot work?
Upvotes: 0
Views: 601
Reputation: 28093
Put following code in your onClick
Intent i = getBaseContext().getPackageManager()
.getLaunchIntentForPackage( getBaseContext().getPackageName() );
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
Upvotes: 4