WebView - Error loading some Web's

3

When I put this link:

link

What is a web that allows you to update the online text in my application without having to edit the App.

But I always get an error: "We are trying to connect to the server." if I use for example Google if it works and other webs but that in particular does not, why is it? I'm also interested in another option for what I want to do.

My code:

public class MainActivity extends AppCompatActivity {

    private WebView view;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        view = (WebView) this.findViewById(R.id.prueba);
        view.getSettings().setJavaScriptEnabled(true);
        view.setWebViewClient(new MyBrowser());
        view.loadUrl("http://www.writeurl.com/text/hc2m5gy29z0byqvo53ug/38nftxs4azvgifrbq6m9"); 
        view.setWebChromeClient(new WebChromeClient()); 
    }

    private class MyBrowser extends WebViewClient {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }
    }

    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if ((keyCode == KeyEvent.KEYCODE_BACK) && view.canGoBack()) {
            view.goBack();
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }

}
    
asked by UserNameYo 09.01.2017 в 21:16
source

1 answer

2

Your code is correct! , but the page is really having problems, for that reason it shows you the text within WebView .

Try another one that you can open in the browser and you will not have a problem.

You can not share the page because it generates an id of the session:

  

hc2m5gy29z0byqvo53ug / 38nftxs4azvgifrbq6m9

but it can not be shared.

You have to use the url generated with the "Publish URL" option, since this url can be opened in a different session:

    
answered by 09.01.2017 / 21:27
source