我期待在我目前正在开发的一个小应用程序中出现相当奇怪的行为。
该应用程序包含两个活动。从第一个活动开始,我通过一个意图启动 webbbrowser。当我在浏览器中按下返回键时,即使我在启动之前手动关闭了应用程序,它也会返回到 SECOND 活动。
1) 第一个活动
final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(mWebShopURL));
startActivity(intent);
第一个活动像这样启动第二个活动
Intent intent = new Intent(getApplicationContext(), SecondActivity.class);
Bundle b = new Bundle();
b.putString("product", mProduct);
intent.putExtras(b);
startActivity(intent);
2)第二个活动->第一个活动
onBackPressed();
AndroidManifest
<activity
android:name=".FirstActivity"
android:label="@string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".SecondActivity"
android:label="@string/app_name"
android:screenOrientation="portrait" >
</activity>