android:scheme 在我的设备上不工作

标签 android url-scheme

我有一个自定义链接:callnumber://12345

我想通过以下方式捕获此链接的点击事件:

<activity android:name=".Test"
                  android:label="@string/app_name">
    <intent-filter>
    <data android:scheme="callnumber"/>
        <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    </intent-filter>
</activity>

我已经在许多设备上进行了测试,例如:Samsung galaxy S2、Samsung Galaxy 2、Motorola XT720 , 它运行完美,但在 HTC Sensation Z710e 上,它没有工作。

我发现在 HTC Sensation Z710e 上,该链接变成 http://www.callnumber.com// 并用浏览器打开。

我像这样转动我的 intent-filter,它起作用了:

<intent-filter>
    <data android:scheme="http" android:host="www.callnumber.com"/>
        <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
</intent-filter>

但是我不想抓取http scheme,因为从custom改成http scheme很容易丢数据。

示例:如果我的链接是 callnumber://12345# ,它将变成 http://www.callnumber.com//12345 ,它丢失了我的字符 '#'

或者如果我的链接是 callnumber://12345#34567 ,它将变成 http://www.callnumber.com//12345 ,它丢失了我的 '#34567'

使用上面的 android 设备列表(HTC Sensation Z710e 除外),它返回我想要的数据。

那么如何为所有 Android 设备或至少为 HTC Sensation Z710e 捕获自定义方案?

非常感谢,

最佳答案

添加数据线如下:

<data android:host="*" android:scheme="callnumber" />

关于android:scheme 在我的设备上不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10246763/

相关文章:

即使没有任何更改,Android 多模块 Gradle 构建也很慢

android - 无法在 Android Studio 3.3 中编译已签名的 APK

iOS 多个应用共享一个 LinkedIn 应用

ios - 在 iOS swift 中的导航应用程序中注册应用程序

javascript - 在手机上使用 Facebook URL 方案向 Facebook 发布消息

ios - Swift - App Delegate 不传递数据

android - 使用 Koin 中的 inject() 函数类型不匹配

java - Android 在复选框上振动

android - 在 MvxFragment 中关闭/隐藏 Android 软键盘

ios - 如何定义以 http ios7 开头的 url 方案