Reload activity in Android

2019-01-03 19:47发布

Is it a good practice to reload an Activity in Android?

What would be the best way to do it? this.finish and then this.startActivity with the activity Intent?

14条回答
等我变得足够好
2楼-- · 2019-01-03 20:51

Android includes a process management system which handles the creation and destruction of activities which largely negates any benefit you'd see from manually restarting an activity. You can see more information about it at Application Fundamentals

What is good practice though is to ensure that your onPause and onStop methods release any resources which you don't need to hold on to and use onLowMemory to reduce your activities needs to the absolute minimum.

查看更多
我想做一个坏孩纸
3楼-- · 2019-01-03 20:52

In an activity you can call recreate() to "recreate" the activity (API 11+)

查看更多
登录 后发表回答