Skip to content

Instantly share code, notes, and snippets.

@chrisjenx
Created July 25, 2012 13:42
Show Gist options
  • Save chrisjenx/3176258 to your computer and use it in GitHub Desktop.
Save chrisjenx/3176258 to your computer and use it in GitHub Desktop.
Restart activity from fragment
//Post it in a handler to make sure it gets called if coming back from a lifecycle method.
new Handler().post(new Runnable() {
@Override
public void run()
{
Intent intent = getActivity().getIntent();
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_NO_ANIMATION);
getActivity().overridePendingTransition(0, 0);
getActivity().finish();
getActivity().overridePendingTransition(0, 0);
startActivity(intent);
}
});
@sayami007
Copy link

Thanks 👍

@MarceloRab
Copy link

Thanks

@AliexieievAndrew
Copy link

thanks!!!

@OdeyFox
Copy link

OdeyFox commented Mar 5, 2019

thank you

@mahdisayeri
Copy link

thanks very gooooooood

@Getrio
Copy link

Getrio commented Jul 1, 2019

thanks :)

@engallote
Copy link

Thank you so much!!

@avansruben
Copy link

Nice, thank you so much!!

@hammood
Copy link

hammood commented May 20, 2020

Thank you dude, you are Awesome.

@Charlex96
Copy link

Thank you

@lzqwebsoft
Copy link

Thanks a lot!

@renaldiadrian98
Copy link

Thanks

@nfaycel
Copy link

nfaycel commented Sep 29, 2021

Thanks a lot.

@Vedp1998
Copy link

Thanks a lot

@noufelbeghlal
Copy link

thank you, my friend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment