通知有效内容中的Firebase click_action工作正常但它会导致第二次启动click_action

时间:2017-12-11 07:43:31

标签: android firebase-cloud-messaging

我正在研究Firebase的click_action用于在应用被杀时通知点击打开活动。它工作正常!但是,在关闭应用程序打开的应用程序后,通常会(Not from notification),但它与click_action中指定的活动相同。

以下是启动屏幕清单中的代码:

<activity
    android:name=".activity.SplashScreen"
    android:screenOrientation="portrait"
    android:theme="@style/LoginScreen">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
</activity>

对于Firebase通知:

<activity android:name=".activity.RequestsActivity">
        <intent-filter>
            <action android:name="RequestsActivity" />
            <category android:name="android.intent.category.DEFAULT"/>
        </intent-filter>
</activity>

当返回主屏幕时,应用程序退出代码:

@Override
public void onBackPressed() {
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_HOME);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    startActivity(intent);
    finish();
    System.exit(0);
}

当前屏幕的流程

通知 - &gt; Click-&gt; RequestActivity-&gt; Back_Click-&gt; HomeScreen-&gt; BackClick-&gt; Exit_App-&gt; Reopen_App-&gt; RequestActivity(但它必须是HomeScreen!)。

0 个答案:

没有答案