ebview中的Facebook聊天按钮未打开Messenger

ebview中的Facebook聊天按钮未打开Messenger

本文介绍了我的网站在android webview中的Facebook聊天按钮未打开Messenger应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个与Facebook聊天选项集成的网站.我对网站进行了网络浏览,可以在我的android应用中看到该聊天按钮,但问题是在单击聊天按钮时,它没有将我重定向到手机中安装的Messenger应用,而是将我重定向到了一个页面在上面写上1.

I have a website which is integrated with facebook chat option. I made a webview of my website and can see that chat button in my android app but the problem is on clicking on the chat button it is not redirecting me to messenger app installed in my phone instead it is redirecting me to a page written 1 on it.

另一方面,在移动设备上以chrome浏览器打开我的网站(在移动查看模式下)时,聊天功能运行良好.

on the other hand while opening my website in chrome on my mobile(in mobile view mode) the chat functionality is working fine.

这是我的MainActivity.java类:

here is my MainActivity.java class:

public class MainActivity extends AppCompatActivity {

private WebView webView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    webView = (WebView)findViewById(R.id.webView);
    WebSettings webSettings = webView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webView.loadUrl("https://geekyvisuals.github.io/website/");
    webView.setWebViewClient(new MyWebViewClient());
}

@Override
public void onBackPressed() {
    if(webView.canGoBack())
        webView.goBack();
    else
        super.onBackPressed();
}


private class MyWebViewClient extends WebViewClient {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        if (Uri.parse(url).getHost().equals("https://geekyvisuals.github.io/website")) {
            // This is my web site, so do not override; let my WebView load the page
            return false;
        }
        // Otherwise, the link is not for a page on my site, so launch another Activity that handles URLs
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
        startActivity(intent);
        return true;
    }
}
}

我该怎么做才能直接从我的android应用程序打开Messenger?

What should i do to open messenger from my android app directly?

推荐答案

对于意图:"使用外部浏览器打开Messenger网址.

For "intent:" open your messenger URL with an external browser.

详细解决方案发布在此处.

这篇关于我的网站在android webview中的Facebook聊天按钮未打开Messenger应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 21:17