When I put this link:
http://www.writeurl.com/text/hc2m5gy29z0byqvo53ug/38nftxs4azvgifrbq6m9
Which is a website that allows you to update the online text in my application without having to edit the App.
But it always gives me an error: "We are trying to connect to the server." If I use, for example, Google if it works and other websites but not that one in particular, why is that? 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);
}
}
Your code is correct! , but the page is actually having problems, so it shows you the text inside the
WebView
.Try another one that you can open in the browser and you will have no problem.
You cannot share the page since it generates a session id:
but it cannot be shared.
You have to use the url generated with the "Publish URL" option, since this url can be opened in a different session: