[英]intent.data is null when launching activity from app link
I looked at related SO but they didn't seem to resolve this issue. 我查看了相关的SO,但他们似乎并未解决此问题。
The app supports app linking and website has .well-known/assetlinks.json. 该应用程序支持应用程序链接,并且网站具有.well-known / assetlinks.json。
When clicking app link in email, say https://staging.xyz.com/v3/info/7vwD2yjW , the 单击电子邮件中的应用程序链接时,说https://staging.xyz.com/v3/info/7vwD2yjW ,
Launching app from a cold start with a valid app link, the intent.data is always null. 从具有有效应用程序链接的冷启动启动应用程序,intent.data始终为null。 However if app had been running or in background, URI intent.data is not null in onNewIntent() and works fine. 但是,如果应用程序已在运行或在后台运行,则URI intent.data在onNewIntent()中不为null,并且可以正常工作。
Not sure what I am missing. 不知道我在想什么。 It's running on a Galaxy J3 Prime, Android 7.0. 它在运行Android 7.0的Galaxy J3 Prime上运行。 Here is the config. 这是配置。 Any ideas how to get intent.data URI from cold start? 任何想法如何从冷启动获取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>
尝试将android:launchMode="singleInstance"
更改为android:launchMode="singleTask"
Turns out this works as-is. 事实证明这是按原样进行的。 There was an exception elsewhere causing launch activity to skip updating from URI data. 在其他地方有一个例外,导致启动活动跳过了从URI数据的更新。 Posting resolution in case it may be useful to anyone else. 发布解决方案,以防其他人使用。
To track down I attached debugger to device process during cold start from app link in Android Studio like so: 为了追踪,我在从Android Studio的应用程序链接冷启动期间将调试器附加到设备进程,如下所示:
adb shell am set-debug-app -w --persistent com.xyz.appname
adb shell am start -a android.intent.action.VIEW -d "https://staging.xyz.com/v3/info/7vwD2yjW" com.xyz.appname
Then Run -> Debug -> select debug config with link 然后运行->调试->选择带有链接的调试配置
An API call is made, and displays a PopupWindow with busy indicator in the launch activity. 进行API调用,并在启动活动中显示带有繁忙指示器的PopupWindow。 The popup was throwing exception: 弹出窗口抛出异常:
BadTokenException: Unable to add window -- token null is not valid; is your activity running?
To get popup working, in onCreate() popup is displayed after activity startup cycle completes 为了使弹出窗口正常工作,活动启动周期完成后,将在onCreate()中显示弹出窗口
activityRootView.post {
handleAppLinkIntent(intent) // show busy popup and do stuff with intent.data
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.