0

This site works well in android browsers but it doesn't work in android webview. I set internet permission and did all things. Who can teach me?

public class MainActivity extends AppCompatActivity { WebView web_view; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); OneSignal.startInit(this).init(); setContentView(R.layout.activity_main); web_view = (WebView)findViewById(R.id.webView); getSupportActionBar().hide(); web_view.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); web_view.getSettings().setDomStorageEnabled(true); web_view.getSettings().setJavaScriptEnabled(true); web_view.setWebViewClient(mWebViewClient); web_view.addJavascriptInterface(new MyJavaScriptInterface(), "android"); web_view.loadUrl("http://182.72.55.182/pms/employee"); } WebViewClient mWebViewClient = new WebViewClient() { @Override public void onPageFinished(WebView view, String url) { view.loadUrl("javascript:window.android.onUrlChange(window.location.href);"); }; }; class MyJavaScriptInterface { @JavascriptInterface public void onUrlChange(String url) { Log.d("hydrated", "onUrlChange" + url); } } } 

2 Answers 2

1

make sure that your regarding website becoming live in everywhere! webview doesn't display any local host website

Sign up to request clarification or add additional context in comments.

Comments

0

Try to put WebViewClient part inside the onCreate.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.