问题
I Am Using Webview For Display html page page have link like
<a href="sms:body=xym">Forward</a>
Which Working Fine In Opera And Default Browser But Not Working In Application using webview
I Try below code but not working
public boolean shouldOverrideUrlLoading(WebView myWebView, String url) {
if (url != null && url.startsWith("sms:?")) {
myWebView.getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
return true;
} else {
return false;
}
}
回答1:
There is a mistake in your code.
It should be
if (url != null && url.startsWith("sms")) {
Also: If you have power over the webpage you are displaying you might want to include the phonegap library if you haven't already. That is meant to handle exactly those things.
回答2:
You need to create a separate SMS intent with proper type and give SMS write permissions to the application.
Intent smsIntent = new Intent(Intent.ACTION_VIEW);
smsIntent.setType("vnd.android-dir/mms-sms");
smsIntent.putExtra("address", "Phone number scrapped from url");
smsIntent.putExtra("sms_body","Body of Message scrapped from url");
startActivity(smsIntent);
来源:https://stackoverflow.com/questions/12661625/pass-smsbody-xyz-to-default-browser-in-android-webview