我希望在用户访问某个网址时启动我的意图:例如,Android市场通过http://market.android.com/网址进行此操作.youtube也是如此.我也希望我也这样做.
我目前正在测试使用大量jQuery动画开发的webapp,我们注意到内置Web浏览器的性能非常差.在Chrome中进行测试时,Web应用程序的性能速度令人难以置信.我只是想知道是否有任何类型的脚本会强制在Chrome for Android中打开一个链接,类似于在iOS中完成的操作.
我通过这种方式添加了一个到我的 Android 应用程序的深层链接:
<activity
android:name=".views.DeepLinkingActivity"
android:exported="true">
<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="example.com"/>
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
当我点击https://example.com
我被重定向到网站。
当我更改它时android:scheme="https"
,android:scheme="appscheme"
它会工作并将我重定向到我的应用程序。
如何强制通过https
方案打开我的应用程序?
更新
我添加了一个子域,但它仍然不起作用。
<activity
android:name=".views.DeepLinkActivity"
android:exported="true">
<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="www.example.ru"/>
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,我有3个活动,MainActivity,SecondaryActivity和TertiaryActivity.我希望SecondaryActivity成为Android 6上特定域的默认应用程序链接处理程序,如本指南中所述.同时,我希望另一个活动TertiaryActivity能够处理来自另一个域的链接,但不能成为默认处理程序,因为我不拥有该域.这是我的AndroidManifest来说明:
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.antonc.applinktest"
xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".SecondaryActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter android:autoVerify="true"> <!-- TRUE -->
<data android:scheme="https"
android:host="secondary.com"/>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
</intent-filter>
</activity>
<activity android:name=".TertiaryActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter android:autoVerify="false"> <!-- FALSE -->
<data android:scheme="https"
android:host="tertiary.com"/>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
</intent-filter>
</activity>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
我阅读了这篇关于应用程序链接的详尽指南,解释了Android上应用程序链接处理和应用程序验证的机制,这里是我在logcat中看到的与应用程序验证相关的消息:
03-25 17:54:45.640 1481-1481/com.google.android.gms D/IntentFilterVerificationReceiver: Received ACTION_INTENT_FILTER_NEEDS_VERIFICATION.
03-25 17:54:45.644 …
Run Code Online (Sandbox Code Playgroud) 我已经创建了一个即时应用程序。我将其上传到我的Google控制台,但出现此错误。
www.kochchy.cz网站尚未通过数字资产链接协议链接到您的应用程序。将应用程序站点与Digital Assets Link链接。
[{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "com.kochchy.instantapptest.app",
"sha256_cert_fingerprints":["A4:A6:74:15:F1:3E:38:3F:93:0F:EF:E3:A6:86:8E:7C:25:45:E8:80:5B:5E:35:70:49:20:DB:F8:CB:D4:FC:E0"]
}
}]
Run Code Online (Sandbox Code Playgroud)
即时和可安装的两个APK都使用相同的ID:com.kochchy.instantapptest.app(每个都在自己的模块清单中定义)
我的基本模块清单如下所示:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.kochchy.instantapptest">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data
android:name="default-url"
android:value="https://www.kochchy.cz" />
<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" />
<data android:scheme="http" />
<data android:host="www.kochchy.cz" />
<data android:pathPattern="/menu" />
</intent-filter>
</activity>
</application>
</manifest> …
Run Code Online (Sandbox Code Playgroud) 我已经根据以下链接实现了Android应用程序链接。
https://developer.android.com/studio/write/app-link-indexing.html
https://developer.android.com/training/app-links
我已经将assetlinks文件托管到我们的域https://ourdomain/.well-known/assetlinks.json中, 而且我已经使用https://developers.google.com/digital-asset-links/tools/generator 和从android studio的应用链接助手也。并通过两种方式获得了验证状态。
现在,当我生成一个已签名的构建并通过Google驱动器链接对其进行测试时。Android应用程序链接按预期工作(单击链接后,应用程序将打开,而无需打开适用于android 6.0及更高版本的消歧对话框)。
将相同版本上传到Play商店后,它不起作用。
以下是清单文件中使用的代码。
<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="<ourdomain>" />
</intent-filter>
Run Code Online (Sandbox Code Playgroud)
编辑:Android应用程序链接将其上传到Play商店后,按预期工作了一天。并在第二天重新开始消除歧义对话。知道可能是什么问题吗?
Play商店中的同一版本在不同的日子给了我两个不同的状态,分别是Ask和Always。
adb shell dumpsys程序包domain-preferred-apps
当我运行上面的命令
android android-studio react-native react-native-android android-app-links
android ×6
intentfilter ×2
browser ×1
deep-linking ×1
launch ×1
mobile ×1
react-native ×1
url ×1