gpt4 book ai didi

android - 自定义 URL 方案 Android

转载 作者:行者123 更新时间:2023-11-29 18:16:20 26 4
gpt4 key购买 nike

嗨,自定义 url 方案对我不起作用。这是我的代码

                <application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".MainActivity" android:label="@string/app_name"
android:launchMode="singleTask">

<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.LAUNCHER" />
<data android:scheme="http" android:host="jinilabs.test" />
</intent-filter>
</activity>

</application>

当我在模拟器浏览器上输入 url - http://jinilabs.test它给我网页不可用错误。这里有什么问题吗?请告诉我

最佳答案

仅仅在栏中输入 URL 是行不通的。您的 url 必须是网页上的可点击链接,因为检查它是否为自定义 url 的浏览器方法仅在单击链接时触发;它只是运行在地址栏中输入的 url(并忽略自定义 url)。点击 this link应该按现在的样子启动您的应用程序。如果它仍然不起作用,您可能需要在 list 文件中添加其他代码。我的看起来像这样:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="appcall.thing"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="4" />

<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".AppCallActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

<intent-filter>
<data android:scheme="stoneware.app.switcher" />
<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>

当然,您必须将此处的一些名称替换为与您的应用相关的名称。我还建议您使用独特的东西而不是 http 开始您的 url 方案,以防 http 混淆浏览器。例如,我的 url 方案是 stoneware.app.switcher://希望这对你有用:)

关于android - 自定义 URL 方案 Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7876163/

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