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 6993053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:42:54+00:00 2026-05-27T19:42:54+00:00

I am newbie to Android development and this webview and webview client is killing

  • 0

I am newbie to Android development and this webview and webview client is killing me. This is my scenario:

  1. I have to load a web page which contains facebook social plugin (used for commenting on that particular url) and I am using WebView for it
  2. When user clicks comment using Facebook, he/she is to be given login page on same webview (instead of opening default browser)
  3. And once the login is successful, the first page (the one containing social plugin) is to be displayed allowing user to comment

What I have to do is emulate the working process of browser i.e. the user when logs in, he/she is automatically granted permission to add facebook comment.

My problem:

I don’t know how to get all the authentication from browser and redirect it back to my app webview. What I want is to do all the process in my app webview rather than going to default browser.

I have checked all the stack overflow questions and most of them advise on using open source Facebook plugins like Facebook connect and Facebook android SDK. Further I got some info on CookieManager, CookieSyncManager, WebViewClient, WebChromeClient but I couldn’t implement on my issue. And the closest I found is this:

How to handle facebook like with confirm in android webview

So folks if you could point me in the right direction, I would be very glad. I am still trying to understand on how to make all the action on a webview and if anything comes I will surely post.

Thanks in advance

Update

I could only implement facebook login but couldn’t implement AOL,Hotmail and Yahoo login. For facebook login just create a custom WebViewClient and on method shouldOverrideUrlLoading

if(url.contains("https://www.facebook.com/connect/window_comm.php")){
    webView.clearHistory();
    webView.loadUrl(remoteUrl);
}
return false;

To allow multiple login I have implemented following technique but it doesn’t work

 if(url.contains("https://www.facebook.com/connect/window_comm.php")){
    String cookieString = cookieManager.getCookie("facebook.com");
    if(cookieString != null){
      cookieManager.setCookie("remoteUrldomain.com", cookieString);
      CookieSyncManager.getInstance().sync();
      webView.clearHistory();
      webView.loadUrl(remoteUrl);
    }
}
return false;

I am still doing my best to find the solution, and anybody out there would guide me in proper direction that would be grateful .
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-27T19:42:55+00:00Added an answer on May 27, 2026 at 7:42 pm

    The answer provided on
    How to handle facebook like with confirm in android webview
    is the best solution I have found so far.What I learnt is that Android WebView doesn’t by default load the popup of html views and for that we need to use WebChromeClient which handles all these.Look at the following code

     private String requestUrl="some web link containing facebook social comment";
     private WebView webView,childView =null;
     private LinearLayout parentLayout;
     private Activity MyActivity;
     @Override
     public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        this.getWindow().requestFeature(Window.FEATURE_PROGRESS);
    
        setContentView(R.layout.main);
    
        getWindow().setFeatureInt(Window.FEATURE_PROGRESS,Window.PROGRESS_VISIBILITY_ON);
        parentLayout =(LinearLayout)findViewById(R.id.parentLayout);
    
    
        MyActivity = this;
    
    
        webView = new WebView(this);
        webView.setLayoutParams(getLayoutParams());
    
        webView.setWebViewClient(new FaceBookClient());
        webView.setWebChromeClient(new MyChromeClient());
        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setAppCacheEnabled(true);
        webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
        webView.getSettings().setSupportMultipleWindows(true);
        webView.getSettings().setSupportZoom(true);
        webView.getSettings().setBuiltInZoomControls(true);
    
        parentLayout.addView(webView);
        webView.loadUrl(requestUrl);
    
     }
    
      private LinearLayout.LayoutParams getLayoutParams(){
        return new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT); 
    }
    
    
        final class MyChromeClient extends WebChromeClient{
        @Override
        public boolean onCreateWindow(WebView view, boolean dialog,
                boolean userGesture, Message resultMsg) {
            childView = new WebView(SmCommentTestActivity.this);
            childView.getSettings().setJavaScriptEnabled(true);
            childView.getSettings().setSupportZoom(true);
            childView.getSettings().setBuiltInZoomControls(true);
            childView.setWebViewClient(new FaceBookClient());
            childView.setWebChromeClient(this);
            childView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
    
    
            parentLayout.addView(childView);
    
    
            childView.requestFocus();
            webView.setVisibility(View.GONE);
    
              /*I think this is the main part which handles all the log in session*/
            WebView.WebViewTransport transport =(WebView.WebViewTransport)resultMsg.obj;
            transport.setWebView(childView);
            resultMsg.sendToTarget();
            return true;
        }
    
    
        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            MyActivity.setProgress(newProgress*100);
        }
    
        @Override
        public void onCloseWindow(WebView window) {
            parentLayout.removeViewAt(parentLayout.getChildCount()-1);
            childView =null;
            webView.setVisibility(View.VISIBLE);
            webView.requestFocus();
        }
    }
    
        private class FaceBookClient extends WebViewClient{
         @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            Log.i("REQUEST URL",url);
            return false;
        }   
    }
    
        @Override
        public void onBackPressed() {
        if(childView != null && parentLayout.getChildCount()==2){
            childView.stopLoading();
            parentLayout.removeViewAt(parentLayout.getChildCount()-1);
            if(webView.getVisibility() == View.GONE)
                webView.setVisibility(View.VISIBLE);
        }else{          
            super.onBackPressed();
        }
    }
    

    This is all one has to do to implement Facebook Social Comment Plugin on Android WebView and if somebody finds any flaw in it,then I would be happy to correct it.And hope,this solution would save and time on any troubled developer like me 😉

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

Sidebar

Related Questions

I am newbie to android. I have client server based application. Server keeps on
Newbee to Android development. I am developing a application, which have three different tabs.
Im newbie into Android development and I have a silly question. How do you
I'm a newbie to the Android development world but have some experience with embedded
I am complete newbie to Android development and I have to make a Home
Extreme Android developer newbie here...well, new to Android development, not development in general. I
[Android Newbie alert] I need to capture the contents of a WebView in a
I am a newbie to Android app development. For 1 of my project, I
I am a newbie to Android and the Eclipse development environment and would like
I'm newbie in Android application development. I just downloaded all SDks and Eclispe. Then

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.