Refresh Current Activity without Delay

让人想犯罪 __ 提交于 2019-12-03 13:25:31

You can try this:

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

this reload's your activity without animation.

This code may work

Intent intent = getIntent();
finish();
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(intent);
Intent intent = new Intent(YourActivity.this, YourActivity.class);
YourActivity.this.startActivity(intent);
finish();

Call this method when you need to refresh your activity.

recreate();

Hardik Joshi

The easiest way is to call onCreate(null); and your activity will be like new. For More info See this.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!