Android Studio WebView blank screen

511
July 30, 2017, at 10:27 AM

When I try using WebView in Android Studio and insert the code needed to use it on my mobile device it only shows a white screen and never loads. I do this code by itself on its own Android Studio project and it loads but when I use it on a different android studio projects with lots more activities and layouts it doesn't work.

public class PrivateBrowser extends AppCompatActivity {
    WebView w1; 
    WebSettings webSettings;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_private_browser);
        w1 = (WebView) findViewById(R.id.webview);
        WebSettings webSettings = w1.getSettings();
        webSettings.setJavaScriptEnabled(true);
        w1.loadUrl("http://www.google.com");
        w1.setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                view.loadUrl(url);
                return true;
            }
        });
    }
}

Layout:

WebView w1;
WebSettings webSettings;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_private_browser);
    w1 = (WebView) findViewById(R.id.webview);
    final WebSettings webSettings = w1.getSettings();
    webSettings.setJavaScriptEnabled(true);
    w1.clearCache(true);
    w1.loadUrl("http://www.google.com");
    w1.setWebViewClient(new WebViewClient() {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            w1.clearCache(true);
            w1.clearHistory();
            return true;
        }
    });
}
Rent Charter Buses Company
READ ALSO
what is default size of string constant pool in java

what is default size of string constant pool in java

I want to understand is there any default size given to string constant pool ? is there any variation in string constant pool in different version on java ?Can any one please let me know what is default size of String constant pool

489
JAVA array concatenation from two different arrays

JAVA array concatenation from two different arrays

How to concatenate each and every number from 2 arrays and then give the output individually of the new noformed?

461
Why does Java 2D array initialization go against intuition?

Why does Java 2D array initialization go against intuition?

Why do multidimensional arrays behave opposite from what you would expect when creating them? An int[][] array means that I should have an array of arrays of intsI would read it backwards starting from the rightmost brackets: ((int)[])[]

425