Android APP 打开QQ客服,不能直接打开,现在的模式是通过WebView打开链接跳转。前提是你设置的QQ是通过QQ推广。需要自己去通过一下,QQ推广验证地址(http://shang.qq.com/v3/index.html).
以下是源码(好使的记得留言好评下):
主界面xml就是一个WebView.
private void initView(){
web = (WebView) findViewById(R.id.web);
//判断并启动QQ
web.getSettings().setJavaScriptEnabled(true);
String url ="http://wpa.qq.com/msgrd?v=3&uin=1075158766&site=qq&menu=yes";
web.loadUrl(url);
web.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
if (url.startsWith("http") || url.startsWith("https")) { //http和https协议开头的执行正常的流程
return super.shouldInterceptRequest(view, url);
} else { //其他的URL则会开启一个Acitity然后去调用原生APP
Intent in = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(in);
return null;
}
}
});
}
---------------------
作者:直到世界尽头szk
来源:CSDN
原文:https://blog.csdn.net/qq_24823401/article/details/78971864