Android Webview JAVA

Hibrit uygulamalar için Webview kulanımı  






ekrana webview ekledikten sonra...


//android manifest dosyası
<uses-permission android:name="android.permission.INTERNET"></uses-permission>


 //webview id tanimi
            WebView webview = (WebView) findViewById(R.id.webview);
            webview.getSettings().setJavaScriptEnabled(true);
            //internet url adresi tanimi
            webview.loadUrl("https://www.okulistik.com");
            //ProgressDialog id
            final ProgressDialog progress = ProgressDialog.show(this, "Geleceği Yazanlar", "Yükleniyor....", true);
            progress.show();
            webview.setWebViewClient(new WebViewClient() {

                @Override
                public void onPageFinished(WebView view, String url) {
                    super.onPageFinished(view, url);
                    Toast.makeText(getApplicationContext(), "Sayfa yüklendi", Toast.LENGTH_SHORT).show();
                    progress.dismiss();
                }

                public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
                    Toast.makeText(getApplicationContext(), "Bir hata oluştu", Toast.LENGTH_SHORT).show();
                    progress.dismiss();
                }
            });

        //belirtilen tarayicida acmak
        //webview.getSettings().setUserAgentString("Mozilla/5.0 (Windows NT 6.1; rv:15.0) Gecko/20120716 Firefox/15.0a2");

Related Posts

Android Webview JAVA
4/ 5
Oleh