【发布时间】:2012-04-20 13:01:28
【问题描述】:
我有一个自定义链接: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>
我已经在许多设备上进行了测试,例如:三星 Galaxy S2、三星 Galaxy 2、摩托罗拉 XT720 ,它运行完美,但在 HTC Sensation Z710e 上却无法运行。
我发现在HTC Sensation Z710e上,该链接变成http://www.callnumber.com//并用浏览器打开。
我像这样转动了我的意图过滤器,它起作用了:
<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方案,因为当它从自定义更改为http方案时很容易丢失数据。
示例:如果我的链接是 callnumber://12345# ,它将变成 http://www.callnumber.com//12345 ,它失去了我的字符'#'
或者如果我的链接是 callnumber://12345#34567 ,它将变成 http://www.callnumber.com//12345 ,它失去了我的 '#34567'
使用上述 android 设备列表(HTC Sensation Z710e 除外),它返回的正是我想要的数据。
那么如何为所有 android 设备或至少为 HTC Sensation Z710e 捕获自定义方案?
非常感谢,
【问题讨论】:
标签: android url-scheme