My problem is that if there is a button on a website, then it will appear on the some page when the user click it . i want to enable function when the information is displayed . Please help me.
private WebView webView; private ProgressBar progressXml; private RelativeLayout WaitPageXml; // waiting page for user private RelativeLayout NoInternetPage;// page for no conection display for youser
protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState);
setContentView(R.layout.phone_number);
webView = findViewById(R.id.WebViewXml);
progressXml = findViewById(R.id.progressXml);
WaitPageXml = findViewById(R.id.WaitPageXml);
webView = findViewById(R.id.WebViewXml);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setUseWideViewPort(true);
webView.setInitialScale(15);
WebSettings mWebSettings = webView.getSettings();
webView.getSettings().setUseWideViewPort(true);
WebSettings webSettings = webView.getSettings();
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setDomStorageEnabled(true);
webView.getSettings().setPluginState(WebSettings.PluginState.ON);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webView.getSettings().setSupportMultipleWindows(true);
webView.getSettings().setSupportZoom(true);
mWebSettings.setAllowFileAccess(true);
mWebSettings.setAllowFileAccess(true);
mWebSettings.setAllowContentAccess(true);
webView.addJavascriptInterface(new MyJavaScriptInterface(),
"android");
webView.setWebViewClient(new WebViewClient() {
@Override
public void onPageStarted(WebView view, String url, Bitmap
favicon) {
if (isOnline()) {
progressXml.setVisibility(View.VISIBLE);
WaitPageXml.setVisibility(View.VISIBLE);
super.onPageStarted(view, url, favicon);
} else {
super.onPageStarted(view, url, favicon);
NoInternetPage.setVisibility(View.VISIBLE);
}
}
@Override
public void onPageFinished(WebView view, String url) {
progressXml.setVisibility(View.GONE);
WaitPageXml.setVisibility(View.GONE);
NoInternetPage.setVisibility(View.GONE);
});
webView.loadUrl("https://......");
@Override
public void onBackPressed() {
if (webView.canGoBack()) {
webView.goBack();
} else {
super.onBackPressed();
}
}
public boolean isOnline() { //for test conection.... ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); @SuppressLint("MissingPermission") NetworkInfo netInfo = cm.getActiveNetworkInfo(); if (netInfo != null && netInfo.isConnectedOrConnecting()) { return true; } else { return false; } }
unfortunately ,the rosponse was not executed by the site