Android activity restart

后端 未结 3 2039
醉梦人生
醉梦人生 2020-12-17 05:17


I am having a confusion in restarting an activity.. I have two function that works well for the same task. Please guide me which is best and why?

publ         


        
3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-17 06:02

    I think this is a cleaner way for your requirement.

        Intent intent = getIntent();
        overridePendingTransition(0, 0);
        intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
        finish();
        overridePendingTransition(0, 0);
        startActivity(intent);
    

提交回复
热议问题