2013-05-28 42 views
0

I have a WebView that loads a page that have links that contain "sms:// or tel://". Im trying to create an intent filter that will launch another activity when an user clicks one of these links. For some reason my activity that i created to handle this links is not being called.如何处理<a href="sms://"> in my own webview?

This is the intent filter that i try to create.

<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

Never mind figure it out. simple mistake.

<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> 
0

Another way to handle this is to create a WebClient for your Webview. This will then allow you to use shouldOverrideUrlLoading() to check each url clicked. Then if url begins with tel: or sms: you are able to redirect to a new intent.

if(url.startsWith("tel:")){ 
Intent telIntent = new Intent(Intent.ACTION_DIAL, Uri.parse(url)); 
     startActivity(telIntent); 
     return true; 
} 

Webview "mailto:" link & "tel:" link work using Intent.ACTION_VIEW, but how do I add unique Subject ie for "mailto:" link