Android 自定义 URL 方案
您好,自定义 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>
在模拟器浏览器上输入网址时的代码 - http://jinilabs.test 它给我网页不可用错误。 这里有什么问题吗?请告诉我
Hi custom url scheme is not working for me. Here is my code
<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>
when I type the url on the emulator browser - http://jinilabs.test
It is giving me web page not available error.
Is there anything wrong here? Plz let me know
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
仅仅在栏中输入 URL 是不行的。您的 url 必须是网页上的可点击链接,因为检查其是否为自定义 url 的浏览器方法仅在单击链接时才会触发;它只是运行在地址栏中输入的 url(并忽略自定义 url)。
单击此链接应该会像现在一样启动您的应用程序。如果仍然不起作用,您可能需要在清单文件中添加其他代码。我的看起来像这样:
当然,您必须将此处的一些名称替换为与您的应用程序相关的名称。我还建议您使用独特的 URL 方案而不是 http 来启动您的 url 方案,以防 http 使浏览器感到困惑。例如,我的网址方案是 Stoneware.app.switcher://
希望这对您有用:)
Simply typing the URL into the bar won't do it. Your url needs to be a clickable link on a webpage because the browser method that checks if it's a custom url only fires when a link is clicked; it simply runs url's that are entered in the address bar(and ignores custom urls).
Clicking this link should launch your app as it is now. If it still doesn't work, you may need additional code in your manifest file. Mine looked like this:
Of course, you will have to substitute some of the names in here for names relative to your app. I would also recommend starting your url scheme with something unique rather than http in case the http is confusing the browser. My url scheme, for example was stoneware.app.switcher://
Hopefully this can be of some use to you :)
将此代码添加到清单文件:
然后尝试。
Add this code to manifest file :
and then try.