Lompat ke konten Lompat ke sidebar Lompat ke footer

Widget HTML #1

Membuat Webview jika tombol di klik masuk ke activity sesuai format

 Fungsi Tambahan Ketika Back Akan :

//fungsi back dan deklarasi ketika ada webview
@Override
public void onBackPressed() {
WebView webView = (WebView) findViewById(R.id.webviewUtama);
if (webView.canGoBack()) {
webView.goBack();
}else {
super.onBackPressed();
}
}

 

 

WebView webView = (WebView) findViewById(R.id.webviewUtama);
webView.getSettings().setLoadsImagesAutomatically(true);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setDomStorageEnabled(true);

// Tiga baris di bawah ini agar laman yang dimuat dapat
// melakukan zoom.
webView.getSettings().setSupportZoom(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setDisplayZoomControls(false);
webView.getSettings().setUserAgentString(null);

// Baris di bawah untuk menambahkan scrollbar di dalam WebView-nya
webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);

//------------------------------//
//next aktifity
webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
webView.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {

//deteksi dalam html apakah ada (string) maka akan berubah fungsi ke sini dan di deklarasi
if (url.startsWith("tel:") || url.startsWith("sms:") || url.startsWith("smsto:") || url.startsWith("mailto:") || url.startsWith("mms:") || url.startsWith("mmsto:")) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);
return true;
} else {
view.loadUrl(url);
}
if (url.startsWith("favorite:htt")) {
webView.loadUrl("https://ranairucreation.000webhostapp.com/index.php");
LayoutInflater objek2 = getLayoutInflater();
View v2 = objek2.inflate(R.layout.layer_favorite, null);
AlertDialog.Builder a = new AlertDialog.Builder(MainActivity.this);
a.setView(v2);
a.show();
a.setCancelable(true);
}
return false;
}

public void onPageFinished(WebView view, String url) {
// do your stuff here
ProgressBar pg = findViewById(R.id.loading);
pg.setVisibility(View.GONE);
}
});
webView.loadUrl("https://ranairucreation.000webhostapp.com/index.php");

Posting Komentar untuk "Membuat Webview jika tombol di klik masuk ke activity sesuai format"