1. sylsau's Avatar
    Hello,

    In that tutorial, you are going to learn how to load an external web site into your Android application with Android Studio. To load an external web site into an Android Application, we are going to use the WebView component available in the Android SDK.

    [Tutorial] Load an external Web Site in a WebView on Android-1-vcswc9iodxjuxhzircd_ow.png

    Note that you can discover this tutorial in video on YouTube :



    The first thing to do is to add the internet permission to the Android Manifest because we are going to load data from the network.

    In the Java code of the Main Activity, we are going to create a new instance of the WebView object. We enable Javascript on this WebView instance and then, we set a WebViewClient object instance on the WebView.

    To avoid some memory leaks with the WebView and its internal state, we don’t forget to call the destroy method of the WebView instance used in the onDestroy method of our Main Activity.

    This gives us the following code :

    Code:
    package com.ssaurel.webview;
    
    import android.os.Bundle;
    import android.support.v7.app.AppCompatActivity;
    import android.webkit.WebView;
    import android.webkit.WebViewClient;
    
    public class MainActivity extends AppCompatActivity {
    
        private WebView webView;
    
        @override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            webView = new WebView(this);
            webView.getSettings().setJavaScriptEnabled(true);
            webView.setWebViewClient(new WebViewClient());
            webView.loadUrl("https://www.ssaurel.com/blog");
            setContentView(webView);
        }
    	
        @override
        protected void onDestroy(){
            super.onDestroy();
    
            if (webView != null) {
              webView.destroy();
            }
        }
    }
    Last step is to run your Android Application to enjoy the SSaurel’s Blog loaded in a WebView :



    To discover more tutorials on Android development, you can subscribe to the SSaurel’s Channel on YouTube : https://www.youtube.com/channel/UCXo...g1UGjgWX1JRvlw

    Don't hesitate to try this tutorial and give me your feedback.

    Thanks.

    Sylvain
    pkcable likes this.
    10-02-2017 08:17 AM
  2. jasonandrews25788's Avatar
    great tutorial
    10-03-2017 06:15 PM
  3. sylsau's Avatar
    great tutorial
    Thanks.

    Don't hesitate to discover the other tutorials on my YouTube Channel
    10-05-2017 03:21 AM

Similar Threads

  1. Samsung S6 Galaxy makes ear deafening on the receiver's side
    By Android Central Question in forum Ask a Question
    Replies: 1
    Last Post: 10-03-2017, 10:30 AM
  2. Why is my Samsung s7 rebooting in my house but okay everywhere else?
    By Android Central Question in forum Ask a Question
    Replies: 2
    Last Post: 10-02-2017, 10:32 AM
  3. How can i reset my password again in gionee s6s when guest mood is on?
    By Android Central Question in forum Ask a Question
    Replies: 0
    Last Post: 10-02-2017, 08:03 AM
  4. Android touch panel upgrade
    By Android Central Question in forum Ask a Question
    Replies: 0
    Last Post: 10-02-2017, 07:41 AM
  5. volume call problem on Samsung S8
    By Android Central Question in forum Samsung Galaxy S8 & S8+
    Replies: 0
    Last Post: 10-02-2017, 07:32 AM

Tags for this Thread

LINK TO POST COPIED TO CLIPBOARD