邮寄地址:链接不支持在Android的? [英] mailto: links unsupported in Android?
问题描述
我没有一个真正的Android设备,所以我用模拟器为我所有的发展,现在,是的mailto:网页链接真的不支持的Android设备上的2.1及以下? 2.2工作,但每次我点击的mailto:在1.6或2.1,甚至,我得到一个[不支持的动作]对话框
链接。任何人只要有一个真实的设备要测试这一点?
I dont have a real Android device so I'm using emulators for all my development for now, are mailto: web links really unsupported on Android devices 2.1 and below? 2.2 works, but every time I click a mailto:
link on 1.6 or 2.1 even, I get an [unsupported action] dialog. Anybody with a real device want to test this out?
推荐答案
您必须自己处理它在WebViewClient
You have to handle it yourself in a WebViewClient
public class MyWebViewClient extends WebViewClient {
Activity mContext;
public MyWebViewClient(Activity context){
this.mContext = context;
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if(url.startsWith("mailto:")){
MailTo mt = MailTo.parse(url);
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_EMAIL, new String[]{mt.getTo()});
i.putExtra(Intent.EXTRA_SUBJECT, mt.getSubject());
i.putExtra(Intent.EXTRA_CC, mt.getCc());
i.putExtra(Intent.EXTRA_TEXT, mt.getBody());
mContext.startActivity(i);
view.reload();
return true;
}
view.loadUrl(url);
return true;
}
}
在你的活动你保持引用 MyWebViewClient
并将其分配给你的的WebView
与 setWebViewClient(mWebClient)
。
In your activity you keep a reference to MyWebViewClient
and assign it to your webview
with setWebViewClient(mWebClient)
.
这篇关于邮寄地址:链接不支持在Android的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!