Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6783699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:53:55+00:00 2026-05-26T16:53:55+00:00

I am trying to implement facebook like functionality using android webview. It is working

  • 0

I am trying to implement facebook like functionality using android webview. It is working fine without “confirm” dialog. But its not working when like needs confirmation. Here is the code snippet i am using.

    private void setUpWebView() {
    likeWebView.setVerticalScrollBarEnabled(false);
    likeWebView.setHorizontalScrollBarEnabled(false);
    likeWebView.setWebViewClient(new FacebookWebViewClient());
    likeWebView.setWebChromeClient(new MyChromeClient());
    likeWebView.getSettings().setJavaScriptEnabled(true);
     String url = getFacebookLikeUrl();
    likeWebView.loadUrl(url);
 }

I am also setting ViewClient and WebChromeClient.

private String getFacebookLikeUrl() {
    return "http://www.facebook.com/plugins/like.php?" + "href="
            + URLEncoder.encode(mUrl) + "&access_token="
            + URLEncoder.encode(facebook.getAccessToken());
}

Please help me out to solve this issue. Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:53:56+00:00Added an answer on May 26, 2026 at 4:53 pm

    Facebook like confirmation opens confirm_widget in new window. So your webview should support Multiple Window opening. for this setJavaScriptCanOpenWindowsAutomatically(true) and setSupportMultipleWindows(true) for your webview-

     private void setUpWebView() {
        likeWebView = new WebView(getContext());
        likeWebView.setWebViewClient(new FacebookWebViewClient());
        likeWebView.setWebChromeClient(new MyChromeClient());
        final WebSettings webSettings = likeWebView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
        webSettings.setSupportMultipleWindows(true);
        String url = getFacebookLikeUrl();
        likeWebView.loadUrl(url);
        likeWebView.setLayoutParams(FILL);
        mContent.addView(likeWebView);
    }
    

    Facebook like confirmation calls onCreateWindow() method. SO override the onCreateWindow method in WebChromeClient –

    final class MyChromeClient extends WebChromeClient {
    
        // Add new webview in same window
        @Override
        public boolean onCreateWindow(WebView view, boolean dialog,
                boolean userGesture, Message resultMsg) {
            WebView childView = new WebView(getContext());
            childView.getSettings().setJavaScriptEnabled(true);
            childView.setWebChromeClient(this);
            childView.setWebViewClient(new FacebookWebViewClient());
            childView.setLayoutParams(FILL);
            mContent.addView(childView);
            WebView.WebViewTransport transport = (WebView.WebViewTransport) resultMsg.obj;
            transport.setWebView(childView);
            resultMsg.sendToTarget();
            return true;
        }
    
        // remove new added webview whenever onCloseWindow gets called for new webview.
        @Override
        public void onCloseWindow(WebView window) {
            mContent.removeViewAt(mContent.getChildCount() - 1);
        }
    }
    

    confirm_widget for like calls onCloseWindow when user click either Like or Cancel. On this method remove last added webview.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to implement the Facebook Like Button but its not working. In
I'm trying to implement the facebook 'like' button my site, but I'm having a
I am trying to implement the Facebook Like button on my site, but rather
I'm trying to implement a Facebook Like button for a website. I'm working in
trying to implement a dialog-box style behaviour using a separate div section with all
I'm trying to implement single sign-on using facebook in my ruby sinatra app. So
I'm trying to implement a Facebook like button within an iframe of a constrained
I'm trying to implement Facebook Connect on a website with .NET MVC using C#.
I'm trying to implement a Facebook like toolbar on the bottom of the screen
I am trying to implement content browsing like it is done on Facebook when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.