Evi*_*arS 16 url android url-scheme intentfilter android-manifest
我已经研究了大多数自定义URL方案问答,但我没有找到可能的答案.
我想通过点击浏览器中的某个URL(移动设备上的任何一个)来启动我的应用程序,问题是我的给定URL无法修改,因为它也提供IOS应用程序,它看起来像这样:
"myapp:// http://www.name.com/path/path2/ "
我不知道如何处理"myapp:// http://"并构建一个正确的意图过滤器,我尝试的一切都行不通.任何帮助将不胜感激,如果我错过了相关的答案,请不要道歉.
这是我到目前为止所尝试的:
<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>
Run Code Online (Sandbox Code Playgroud)
注意:我尝试使用/不使用导出:true
Evi*_*arS 12
正如CommonsWare所说,我需要创建一个Scheme时给定的URI不是一个有效的URI,因此该方案不起作用,应用程序也没有启动.在解释之后,服务器端人员确信将URI更改为myapp:// ...并且它像魔术一样工作:).
活动现在看起来像这样:
<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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
31173 次 |
| 最近记录: |