How can I finish all activities and start from main after my application is automatically destroyed and created again? This can happen for example when a user changes a system font. My application class contains the big amount of data which is used by many activities and it gets cleared on app restart, the state becomes invalid, that's why I have to return to the launcher activity and clear all the history.
I tried to call the following code in application's onCreate() method as suggested by Marc here, but it doesn't work:
Intent i = getBaseContext().getPackageManager().getLaunchIntentForPackage( getBaseContext().getPackageName() );
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);