我有一个WebView,它加载一个包含“sms://或tel://”链接的页面。我试图创建一个意图过滤器,当用户点击其中一个链接时,它会启动另一个活动。出于某种原因,我创建的用于处理此链接的活动未被调用。
这是我尝试创建的intent过滤器。
<intent-filter>
<action android:name="android.intent.action.VIEW"></action>
<category android:name="android.intent.category.DEFAULT"></category>
<category android:name="android.intent.category.BROWSABLE"></category>
<data android:scheme="tel" android:host="path" />
</intent-filter>
答案 0 :(得分:0)
别介意弄清楚。 简单的错误。
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="tel"/>
</intent-filter>
答案 1 :(得分:0)
处理此问题的另一种方法是为Webview创建WebClient。这将允许您使用shouldOverrideUrlLoading()来检查单击的每个URL。然后,如果url以tel:或sms开头:您可以重定向到新意图。
if(url.startsWith("tel:")){
Intent telIntent = new Intent(Intent.ACTION_DIAL, Uri.parse(url));
startActivity(telIntent);
return true;
}