This is a follow up question to this question:
Force application to restart on first activity
I am trying to restart my application from a fragment like that:
Toast.makeText(getActivity(), "Restarting app", Toast.LENGTH_SHORT).show();
Intent i = getActivity().getBaseContext().getPackageManager()
.getLaunchIntentForPackage(getActivity().getBaseContext().getPackageName() );
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
getActivity().finish();
The code does nothing. The finish()
is the only thing working for some reason. If I remove the finish()
, nothing happens. Why is that?
Activity
? If so, which one? Please post your manifest. What exactly are you trying to accomplish? – Scatterbrain