[英]Android - Activity persist as destroyed after call startActivity
這是問題的場景:
活動“ A”具有一個按鈕,而不是調用startActivityB。
活動“ B”有一個按鈕,然后調用finish()。 因此,應用再次顯示活動“ A”。
現在,如果我將活動稱為“ B”,則屬性mDestroyed = true
問題: 當我第二次訪問B時,B被破壞了
為什么在我調用startActivity之后B繼續被破壞?
有人可以幫我嗎?
清單文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="br.com.xxxxxx">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="xxx"
android:supportsRtl="false"
android:theme="@style/MyMaterialTheme">
<activity
android:name=".BaseActivity"
android:screenOrientation="portrait" />
<activity
android:name=".A"
android:screenOrientation="portrait" />
<activity
android:name=".B"
android:screenOrientation="portrait" />
</application>
</manifest>
活動B的方法:
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
活動A方法:
@Override
public void onClick(View view) {
startActivity(new Intent(MainActivity.this, B.class));
}
finish()
方法調用activity的onDestroy()
。 將finish()
替換為
startActivity(new Intenet(CurrentActivity.this, NewActivity.class));
您當前的活動將在后台進行。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.