This is the problem´s cenary:
The Activity "A" have a button than call startActivity B.
The Activity "B" have a button then call finish(). So the app show Activity "A" again.
Now, If i call activity "B" the property mDestroyed = true
The problem: When i access B a second time B is destroyed
Why B continue destroyed after i call startActivity?
Someone can help me?
ManifestFile:
<?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>
Activity B method:
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
Activity A method:
@Override
public void onClick(View view) {
startActivity(new Intent(MainActivity.this, B.class));
}
finish()
method calls onDestroy()
of activity . Replace finish()
with
startActivity(new Intenet(CurrentActivity.this, NewActivity.class));
Your current activity will be in background.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.