繁体   English   中英

MainAcitivity 不进入 onNewIntent 方法并再次调用 onCreate 即使它是 SingleTask

[英]MainAcitivity Does not enter onNewIntent Method and call onCreate Again even it's SingleTask

以防止应用在点击深层链接后重新加载。 我已经为启动活动 singleTask 设置了午餐模式,并在 onnewintent 方法中处理了任何新意图

   <activity
        android:name=".activities.SplashActivity"
        android:label="@string/app_name"
        android:launchMode="singleTask"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme.Splash">

    </activity>
    <activity
        android:name=".activities.MainActivity"
        android:label="@string/app_name"
        android:launchMode="singleTask"
        android:screenOrientation="portrait"
       >
    </activity>

我也将 maniActivity 设置为 signleTask 以防止每次用户打开深度链接时重新加载。 初始调用 onNewIntent 顺利,但每次重新创建 mainactivity 如何使 MainActivity 调用 onNewIntent 而不是调用 onCreate 我尝试将标志FLAG_ACTIVITY_CLEAR_TOP|FLAG_ACTIVITY_SINGLE_TOP FLAG_ACTIVITY_SINGLE_TOP 添加到 MainActivity 意图,但它不起作用

//splashActivty
@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    Intent launchIntent = new Intent(this, MainActivity.class);
    startActivity(launchIntent);
}

您需要使用setIntent然后在onResume中继续执行。

看看这个链接,我会说 startActivity 可能是个问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM