Android 8.0以上的深连接链接仅在App被杀死时首先开放启动器活动



仅在Android 8.0 上,当打开具有深链接的应用程序时(单击使用已连接的URI的推送通知(,应用程序将打开我的入口点活动,然后打开深链接活动。

在低于8.0的Android上看不到这一点。在这种情况下,它将直接打开深度链接活动,并且不会打开Splash屏幕活动。

不幸的是,应用程序的工作方式是,当调用入口点活动(这是一个飞溅屏幕(时,它将移至另一个活动。这使得在应用程序硬关闭时打开Deep Link非常不可靠,因为当Deep Link活动运行时(大约在Splash屏幕运行后约80ms(,应用程序已经过渡到下一个活动,该活动可能会完全取消深层链接。

为了绕过这一点,我尝试处理启动活动内部的深链接,并将启动模式设置为singletask,singletop和singleSinstance。不幸的是,这些都没有起作用。

我通过使用计时器来解决此问题,通过将飞机屏幕持续200ms的时间比平常更长,但该解决方案似乎很脏,对于所有设备而言似乎并不是非常可靠的。

这是我的飞溅活动和清单中的深连接活动

<activity
 android:name=".activities.LauncherActivity"
 android:excludeFromRecents="true"
 android:taskAffinity="${launcherAffinity}"
 android:theme="@android:style/Theme.Translucent.NoTitleBar">
 <intent-filter>
    <action android:name="android.intent.action.MAIN" />
     <category android:name="android.intent.category.LAUNCHER" />
  </intent-filter>
</activity>

<activity
 android:name=".activities.ParseDeepLinkActivity"
 android:theme="@android:style/Theme.NoDisplay">
 <intent-filter>
  <action android:name="android.intent.action.VIEW" />
   <data
     android:host="*"
     android:scheme="com.deeplink" />
     <category android:name="android.intent.category.DEFAULT" />
     <category android:name="android.intent.category.BROWSABLE" />
  </intent-filter>
  <intent-filter>
   <action android:name="android.intent.action.VIEW" />
     <category android:name="android.intent.category.DEFAULT" />
     <category android:name="android.intent.category.BROWSABLE" />
        <data
         android:scheme="https"
         android:host="deep.link.net"
         android:pathPrefix="/mobile" />
  </intent-filter>
</activity>

这是我的发射器活动

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_launcher);
        startActivity(
                new Intent(this, LoginActivity.class)
                        .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
        finish();
    }

,如果我能像在低于8.0上那样直接打开Deep Link活动,我会喜欢它。如果深处链接在8.0 中发生了变化,我尝试搜索任何文档,但我找不到。

已解决!

问题是在城市航空中。我们的班级扩展了Airsiphreceiver在notifactionpationed方法中的默认返回false,这意味着它也将启动启动器活动。为什么这仅在8.0 中引起问题,我不太确定。这是我解决的方式

 @Override
    protected boolean onNotificationOpened(@NonNull Context context, @NonNull NotificationInfo notificationInfo) {
        Map<String, ActionValue> notificationActions = notificationInfo.getMessage().getActions();
        // Return false here to allow Urban Airship to auto launch the launcher activity
        try{
            return notificationActions.containsKey("^d");
        }catch(Exception e){
            return false;
        }
    }

^d是此处列出的深链接操作的默认键https://docs.airship.com/reference/libraries/android/latest/reference/com/burbanairship/actions/deeplinkactions.html

最新更新