Integrate Facebook into an App with WebView

2

How can I integrate a Facebook page in my application with WebView , I did it in a basic way but it only shows me the header of the page, when I start to scroll down it stays there in the header.

This is my code:

  WebView myWebView = (WebView) this.findViewById(R.id.webView);
    myWebView.setWebViewClient(new WebViewClient());
    //myWebView.loadUrl("https://www.adventistas.org/es/");
    myWebView.setWebViewClient(new Callback());
    myWebView.loadUrl("https://www.facebook.com/adventistasrosarioeste/?ref=br_tf");

How could I make my page that is in the WebView scroll?

    
asked by user62207 07.08.2018 в 22:40
source

1 answer

1

It is correct what you try to do but in this case the class Callback is simply a WebViewClient where you should write about the method shouldOverrideUrlLoading() :

WebView myWebView = (WebView) this.findViewById(R.id.webView);

myWebView.getSettings().setJavaScriptEnabled(true);

myWebView.setWebViewClient(new WebViewClient(){
     @Override
      public boolean shouldOverrideUrlLoading(WebView view, String url) {
          return false;
       }
    });

myWebView.loadUrl("https://www.facebook.com/adventistasrosarioeste/?ref=br_tf");

To ensure the page is loaded and you can see its contents, it is necessary to define the property android:layout_height="match_parent" :

<WebView
    android:id="@+id/webView"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

this would be the result:

Obviously you need permission:

<uses-permission android:name="android.permission.INTERNET"/>
    
answered by 07.08.2018 / 23:10
source