使用intent重新启动当前活动

Zer*_*ero 2 android launch android-intent android-activity

对于我正在开发的应用程序,我想使用intent重新启动当前活动.所以我在MainActivity.class中,我想使用以下内容重新启动MainActivity.class:

Intent intent = new Intent(getApplicationContext(), MainActivity.class);
Run Code Online (Sandbox Code Playgroud)

这会调用onDestroy()但不会重新启动活动.为什么这不起作用?

Rac*_*nda 6

如果您在活动中: this.recreate();

如果你在片段中: getActivity.recreate();

相关链接 :

如何重新启动Android活动

如何重启android中的活动?

Android活动重启