机器人如何创建具有给定格式的myapp自定义URL方案:// HTTP:// [英] Android how to create Custom URL scheme with the given format myapp://http://
问题描述
我已经通过大多数的自定义URL方案Q&放研究; A,我还没有发现我可能的答案。
I have researched through most of the custom URL scheme Q&A and I have not found my possible answer.
我想我的应用程序在浏览器中单击某个URL(任何移动设备上)推出,事情是,我给的网址不能为它提供iOS应用程序以及和它看起来像这样修改:
I want my app to be launched by clicking a certain URL in the browser (any on the mobile device) , the thing is that my given URL cannot be modified as it serves IOS app as well and it looks like this:
的myapp:// http://www.name.com/path/path2/
我不知道如何处理的myapp:// HTTP://,构建适当的意图过滤器,和一切我试图不工作。 任何帮助将AP preciated,如果我错过了一个相关的答案,请除了我的道歉。
I'm not sure how to handle "myapp://http://" and construct a proper intent filter , and everything i tried does not work. Any help will be appreciated , and if I missed a relevant answer please except my apology.
这是我试过到目前为止:
This is what I tried so far :
<activity
android:name="com.myapp.test.SplashScreen"
android:exported="true"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!-- Test for URL scheme -->
<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:host="www.name.com"
android:path="/path/path2/"
android:scheme="http" />
<data
android:host="www.name.com"
android:path="/path/path2/"
android:scheme="https" />
<data android:scheme="myapp" />
</intent-filter>
<!-- End Test for URL scheme -->
</activity>
注意:我/试图与不导出:真正的
Note: I have tried with/without the exported:true
推荐答案
由于CommonsWare给定的URI表示在我需要创建一个计划是不是一个有效的URI这样的方案并没有失效,且应用程序没有启动。在此之后的解释服务器端的家伙们相信的URI改变的myapp:// ...它,像变魔术一样:)。
As CommonsWare said the given URI upon I needed to create a Scheme is not a valid URI thus the scheme didn't not work and the application didn't launch. After this explanation the server side guys were convinced to change the URI to myapp://... and it worked like magic :).
该活动看起来像现在这样:
The Activity looks like this now :
<activity
android:name="com.myapp.test.SplashScreen"
android:exported="true"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!-- Test for URL scheme -->
<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="myapp" />
</intent-filter>
<!-- End Test for URL scheme -->
</activity>
这篇关于机器人如何创建具有给定格式的myapp自定义URL方案:// HTTP://的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!