I have 2 activities Activity1,Activity2 , when i open my application Activity1 will get displayed from there i will navigate to Activity2 and this time Activity1 is in background.
When i am in Activity2 ,i am Activity2 i am opening the settings and changing the language, then system reload the Activity2 . At this point in time i don't want to display activity2 ,i want to restart my application from starting.
Currently i have tried below logic in fragments which i have used in Activity2 to eliminate the crash.
Fragments:
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(
R.layout.point_selection_list_fragment, container, false);
if (savedInstanceState != null) {
Utils.removeFragment(this);
return view;
}
return view;
}
Hope it will help.
Intent i = getBaseContext().getPackageManager().getLaunchIntentForPackage(getBaseContext().getPackageName() );
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
Only problem with this it will not restart the application, only re-create the classes. Thus, any static variables within the classes will retain values from previous runs