gpt4 book ai didi

android - 从应用程序链接启动 Activity 时 intent.data 为空

转载 作者:行者123 更新时间:2023-11-29 02:28:09 25 4
gpt4 key购买 nike

我查看了相关的 SO,但他们似乎没有解决这个问题。

该应用程序支持应用程序链接,网站有 .well-known/assetlinks.json。

单击电子邮件中的应用程序链接时,说 https://staging.xyz.com/v3/info/7vwD2yjW ,

  • 应该出现主要 Activity
  • onCreate() 应该从 intent.data 中获取 URI 数据
  • 主要 Activity 应根据 URI 数据自行更新

使用有效的应用程序链接从冷启动启动应用程序,intent.data 始终为空。但是,如果应用程序一直在运行或在后台运行,则 URI intent.data 在 onNewIntent() 中不为空并且可以正常工作。

不确定我错过了什么。它在 Galaxy J3 Prime Android 7.0 上运行。这是配置。关于如何从冷启动获取 intent.data URI 有什么想法吗?

    <activity
android:name=".activity.MainActivity"
android:launchMode="singleInstance"
android:screenOrientation="portrait">
<tools:validation testUrl="https://staging.xyz.com/v3/info/7vwD2yjW" />

<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

<intent-filter android:autoVerify="true">
<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="xyz.com"
android:pathPattern="/.*/share" />
</intent-filter>

<intent-filter android:autoVerify="true">
<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="xyz.com"
android:pathPattern="/.*/info/.*" />
</intent-filter>

<intent-filter android:autoVerify="true">
<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="*.xyz.com"
android:pathPattern="/.*/share" />
</intent-filter>

<intent-filter android:autoVerify="true">
<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="*.xyz.com"
android:pathPattern="/.*/info/.*" />
</intent-filter>

最佳答案

看看这个 question 。您应该覆盖 onNewIntent 然后处理来自它的数据。

@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
// do stuff with intent
}

关于android - 从应用程序链接启动 Activity 时 intent.data 为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51050539/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com