1

我已经Activity A和它打电话了Activity B。在清单 Activity A 中有 configChanges android:configChanges="locale|orientation|screenSize"

在活动 A 中 - 用于更改语言环境

@Override
public void onConfigurationChanged(Configuration newConfig)
{
    super.onConfigurationChanged(newConfig);
    Resources res = this.getResources();
    res.updateConfiguration(newConfig, null);
    Intent intent = getIntent();
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
    startActivity(intent);
}
  • 用于启动活动 B

    Intent intent = new Intent(this, B.class); 开始活动(意图);

如果我启动 Activity A 并更改语言环境,一切正常。但是,如果我尝试启动 Activity A,然后启动 Activity B,然后转到 Activity A 并更改语言环境,Activity A will not be restarted, it will be destroyed. 如何防止 Activity A 被破坏?

4

1 回答 1

0

Add the flag Intent.FLAG_ACTIVITY_REORDER_TO_FRONT to your Intent. It will reorder an existing Activity from the stack if it is already running.

于 2013-08-08T08:34:34.310 回答