Example usage for android.webkit WebSettings setJavaScriptEnabled

List of usage examples for android.webkit WebSettings setJavaScriptEnabled

Introduction

In this page you can find the example usage for android.webkit WebSettings setJavaScriptEnabled.

Prototype

public abstract void setJavaScriptEnabled(boolean flag);

Source Link

Document

Tells the WebView to enable JavaScript execution.

Usage

From source file:com.bangalore.barcamp.activity.WebViewActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.webview);/*  w ww  .  j a  v a2 s  .  c  om*/
    mDrawerToggle = BCBFragmentUtils.setupActionBar(this, BCBConsts.BARCAMP_BANGALORE);
    webView = (WebView) findViewById(R.id.webView);
    WebSettings websettings = webView.getSettings();
    websettings.setJavaScriptEnabled(true);
    webView.setClickable(true);
    webView.setWebViewClient(new WebViewClient() {
        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            if (url.contains("bcbapp://android")) {
                setUserDetails(url);
            }
            super.onPageStarted(view, url, favicon);
        }

        private void setUserDetails(String url) {
            Intent newIntent = new Intent(WebViewActivity.this, MainFragmentActivity.class);
            newIntent.setData(Uri.parse(url));
            startActivity(newIntent);
            String id = newIntent.getData().getQueryParameter("id");
            String sid = newIntent.getData().getQueryParameter("sid");
            Log.e("data", "id: " + id + " sid: " + sid);
            BCBSharedPrefUtils.setUserData(getApplicationContext(), id, sid);
            BCBSharedPrefUtils.setScheduleUpdated(WebViewActivity.this, true);
            finish();
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            findViewById(R.id.linearLayout2).setVisibility(View.GONE);
            webView.setVisibility(View.VISIBLE);
        }

        @Override
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            showDialog(SHOW_ERROR_DIALOG);
        }

        @Override
        public void onLoadResource(WebView view, String url) {
            if (url.contains("bcbapp://android")) {
                setUserDetails(url);
                Tracker t = ((BarcampBangalore) getApplication()).getTracker();

                // Send a screen view.
                t.send(new HitBuilders.EventBuilder().setCategory("ui_action").setAction("button")
                        .setLabel("Login Success").build());

            }
            super.onLoadResource(view, url);
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            if (url.contains("bcbapp://android")) {
                setUserDetails(url);
                Tracker t = ((BarcampBangalore) getApplication()).getTracker();

                // Send a screen view.
                t.send(new HitBuilders.EventBuilder().setCategory("ui_action").setAction("button")
                        .setLabel("Login Success").build());
                return true;

            }
            if (url.equals(getIntent().getStringExtra(URL))) {
                return true;
            } else if (getIntent().getBooleanExtra(ENABLE_LOGIN, false)) {
                return false;
            }
            Log.e("Action", url);
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse(url));
            startActivity(intent);
            return true;
        }

    });

    String url = getIntent().getStringExtra(URL);
    webView.loadUrl(url);

    Tracker t = ((BarcampBangalore) getApplication()).getTracker();

    // Set screen name.
    t.setScreenName(this.getClass().getName() + url);

    // Send a screen view.
    t.send(new HitBuilders.AppViewBuilder().build());

    // ActionBar actionbar = (ActionBar) findViewById(R.id.actionBar1);
    // actionbar.addAction(new Action() {
    //
    // @Override
    // public void performAction(View arg0) {
    // findViewById(R.id.linearLayout2).setVisibility(View.VISIBLE);
    // webView.setVisibility(View.GONE);
    // webView.reload();
    // }
    //
    // @Override
    // public int getDrawable() {
    // return R.drawable.refresh;
    // }
    // }, 0);

    webView.requestFocus(View.FOCUS_DOWN);

    BCBFragmentUtils.addNavigationActions(this);
    supportInvalidateOptionsMenu();

}

From source file:li.klass.fhem.fragments.AbstractWebViewFragment.java

@SuppressLint("SetJavaScriptEnabled")
@Override/*  www . j av  a 2s .c  o m*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = super.onCreateView(inflater, container, savedInstanceState);
    if (view != null)
        return view;

    view = inflater.inflate(R.layout.webview, container, false);
    assert view != null;

    final WebView webView = (WebView) view.findViewById(R.id.webView);

    WebSettings settings = webView.getSettings();
    settings.setUseWideViewPort(true);
    settings.setLoadWithOverviewMode(true);
    settings.setJavaScriptEnabled(true);
    settings.setBuiltInZoomControls(true);

    final ProgressDialog progressDialog = new ProgressDialog(getActivity());
    progressDialog.setMessage(getResources().getString(R.string.loading));

    webView.setWebChromeClient(new WebChromeClient() {
        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            super.onProgressChanged(view, newProgress);
            if (newProgress < 100) {
                progressDialog.setProgress(newProgress);
                progressDialog.show();
            } else {
                progressDialog.hide();
            }
        }
    });

    webView.setWebViewClient(new WebViewClient() {
        @Override
        public void onReceivedSslError(WebView view, @NotNull SslErrorHandler handler, SslError error) {
            handler.proceed();
        }

        @SuppressWarnings("ConstantConditions")
        @Override
        public void onReceivedHttpAuthRequest(WebView view, @NotNull HttpAuthHandler handler, String host,
                String realm) {
            FHEMServerSpec currentServer = connectionService.getCurrentServer(getActivity());
            String url = currentServer.getUrl();
            String alternativeUrl = trimToNull(currentServer.getAlternateUrl());
            try {

                String fhemUrlHost = new URL(url).getHost();
                String alternativeUrlHost = alternativeUrl == null ? null : new URL(alternativeUrl).getHost();
                String username = currentServer.getUsername();
                String password = currentServer.getPassword();

                if (host.startsWith(fhemUrlHost)
                        || (alternativeUrlHost != null && host.startsWith(alternativeUrlHost))) {
                    handler.proceed(username, password);
                } else {
                    handler.cancel();

                    Intent intent = new Intent(Actions.SHOW_TOAST);
                    intent.putExtra(BundleExtraKeys.STRING_ID, R.string.error_authentication);
                    getActivity().sendBroadcast(intent);
                }

            } catch (MalformedURLException e) {
                Intent intent = new Intent(Actions.SHOW_TOAST);
                intent.putExtra(BundleExtraKeys.STRING_ID, R.string.error_host_connection);
                getActivity().sendBroadcast(intent);
                LOG.error("malformed URL: " + url, e);

                handler.cancel();
            }
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
            if ("about:blank".equalsIgnoreCase(url)) {
                Optional<String> alternativeUrl = getAlternateLoadUrl();
                if (alternativeUrl.isPresent()) {
                    webView.loadUrl(alternativeUrl.get());
                }
            } else {
                onPageLoadFinishedCallback(view, url);
            }
        }
    });

    return view;
}

From source file:it.rignanese.leo.slimtwitter.MainActivity.java

private void setUpWebViewDefaults(WebView webView) {
    WebSettings settings = webView.getSettings();

    // Enable Javascript
    settings.setJavaScriptEnabled(true);

    // Use WideViewport and Zoom out if there is no viewport defined
    settings.setUseWideViewPort(true);//from  w  w  w .  ja v a 2  s.  c  o m
    settings.setLoadWithOverviewMode(true);

    // Enable pinch to zoom without the zoom buttons
    settings.setBuiltInZoomControls(true);

    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) {
        // Hide the zoom controls for HONEYCOMB+
        settings.setDisplayZoomControls(false);
    }

    // Enable remote debugging via chrome://inspect
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        WebView.setWebContentsDebuggingEnabled(true);
    }
}

From source file:com.rfo.basic.Web.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.v(LOGTAG, "onCreate");
    super.onCreate(savedInstanceState);
    ContextManager cm = Basic.getContextManager();
    cm.registerContext(ContextManager.ACTIVITY_WEB, this);
    cm.setCurrent(ContextManager.ACTIVITY_WEB);

    setContentView(R.layout.web);//from  w  w w . ja va 2s.  c om
    View v = findViewById(R.id.web_engine);

    Intent intent = getIntent();
    int showStatusBar = intent.getIntExtra(EXTRA_SHOW_STATUSBAR, 0);
    int orientation = intent.getIntExtra(EXTRA_ORIENTATION, -1);

    showStatusBar = (showStatusBar == 0) ? WindowManager.LayoutParams.FLAG_FULLSCREEN // do not show status bar
            : WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN; // show status bar
    getWindow().setFlags(showStatusBar, showStatusBar);

    setOrientation(orientation);

    engine = (WebView) v;

    WebSettings webSettings = engine.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setBuiltInZoomControls(true);
    webSettings.setSupportZoom(true);
    webSettings.setAppCacheEnabled(true);
    webSettings.setDatabaseEnabled(true);
    webSettings.setDomStorageEnabled(true);
    webSettings.setAllowFileAccess(true);
    webSettings.setGeolocationEnabled(true);
    webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);

    engine.addJavascriptInterface(new JavaScriptInterface(), "Android");

    engine.setWebViewClient(new MyWebViewClient());

    aWebView = new TheWebView(this);

    engine.setWebChromeClient(new WebChromeClient() {
        @Override
        public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
            //Required functionality here
            return super.onJsAlert(view, url, message, result);
        }
    });

}

From source file:no.digipost.android.gui.metadata.ExternalLinkWebview.java

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ((DigipostApplication) getApplication()).getTracker(DigipostApplication.TrackerName.APP_TRACKER);
    setContentView(R.layout.activity_externallink_webview);
    Bundle bundle = getIntent().getExtras();
    fileUrl = bundle.getString("url", "https://www.digipost.no");

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);/*from w ww .j a  v a2  s .  c  o m*/
    actionBar = getSupportActionBar();
    if (actionBar != null) {
        setActionBarTitle(fileUrl);
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setBackgroundDrawable(new ColorDrawable(0xff2E2E2E));

        if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Window window = this.getWindow();
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.setStatusBarColor(
                    ContextCompat.getColor(this, R.color.metadata_externalbrowser_top_background));
        }
    }

    progressSpinner = (ProgressBar) findViewById(R.id.externallink_spinner);
    webView = (WebView) findViewById(R.id.externallink_webview);
    WebSettings settings = webView.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
    settings.setDomStorageEnabled(true);
    settings.setLoadWithOverviewMode(true);
    settings.setUseWideViewPort(true);
    settings.setSupportZoom(true);
    settings.setBuiltInZoomControls(true);
    settings.setDisplayZoomControls(false);
    settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
    webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
    webView.setScrollbarFadingEnabled(true);
    enableCookies(webView);
    webView.setWebViewClient(new WebViewClient() {

        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
            if (firstLoad) {
                progressSpinner.setVisibility(View.GONE);
                webView.setVisibility(View.VISIBLE);
                firstLoad = false;
            }
            setActionBarTitle(view.getUrl());
        }
    });

    webView.setDownloadListener(new DownloadListener() {
        @Override
        public void onDownloadStart(final String url, final String userAgent, final String content,
                final String mimeType, final long contentLength) {
            fileName = URLUtil.guessFileName(url, content, mimeType);
            fileUrl = url;
            onComplete = new BroadcastReceiver() {
                @Override
                public void onReceive(Context context, Intent intent) {
                    String action = intent.getAction();
                    if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action)) {
                        showDownloadSuccessDialog(context);
                    }
                }
            };

            registerReceiver(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
            if (!mimeType.equals("text/html")) {
                if (FileUtilities.isStorageWriteAllowed(getApplicationContext())) {
                    showDownloadDialog(userAgent, content, mimeType, contentLength);
                } else {
                    showMissingPermissionsDialog();
                }
            }
        }
    });

    if (FileUtilities.isStorageWriteAllowed(this)) {
        webView.loadUrl(fileUrl);
    } else {
        showPermissionsDialog();
    }
}

From source file:com.anxpp.blog.fragment.AboutFragment.java

@SuppressLint("SetJavaScriptEnabled")
private void initView() {
    webView = (WebView) getView().findViewById(R.id.webView);
    //      webView.setVisibility(View.GONE);
    webView.setWebChromeClient(new WebChromeClient() {
        public void onProgressChanged(WebView view, int progress) {
            Activity activity = getActivity();
            /**//from   w ww  . jav a 2s . c om
             * ?Fragment???
             * I am not sure why are you getting this error, 
             * i think it should be something like NullPointerException. 
             * Try next: 
             *     Evert time you calling getActivity() on Fragment instance you should be sure,
             *     that fragment is actually have this Activity. 
             *     Because when your webview is loading you are calling this function:
             * */
            if (activity == null)
                return;
            activity.setTitle("Loading..." + progress + "%");
            activity.setProgress(progress * 100);
            if (progress == 100) {
                activity.setTitle(R.string.app_name);
                webView.setVisibility(View.VISIBLE);
            }
        }
    });
    webView.setWebViewClient(new WebViewClient() {
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            Toast("shouldOverrideUrlLoading");
            view.loadUrl(url);
            return true;
        }
    });
    //??
    WebSettings webSettings = webView.getSettings();
    //?
    //webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
    webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
    //?js
    webSettings.setJavaScriptEnabled(true);
    //? ?
    webSettings.setUseWideViewPort(false); //??
    webSettings.setLoadWithOverviewMode(true); // ??
    webView.loadUrl("http://anxpp.com");
    //
    webView.setWebViewClient(new WebViewClient() {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            //trueWebViewfalse??
            view.loadUrl(url);
            return true; //false?
        }
    });
    webView.setOnKeyListener(new View.OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (event.getAction() == KeyEvent.ACTION_DOWN) {
                if (keyCode == KeyEvent.KEYCODE_BACK && webView.canGoBack()) { // ?
                    webView.goBack(); //?
                    return true; //?
                }
            }
            return false;
        }
    });
}

From source file:com.zbrown.droidsteal.activities.HijackActivity.java

private void setupWebView() {
    webview = (WebView) findViewById(R.id.webviewhijack);
    webview.setWebViewClient(new MyWebViewClient());
    WebSettings webSettings = webview.getSettings();
    webSettings.setUserAgentString(/*from w w  w. ja  v a2  s. c o  m*/
            "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36");
    webSettings.setJavaScriptEnabled(true); //Blah blah JavaScript is scary blah blah
    webSettings.setAppCacheEnabled(false);
    webSettings.setBuiltInZoomControls(true);
    webSettings.setDisplayZoomControls(false);
    webview.setWebChromeClient(new WebChromeClient() {
        @Override
        public void onProgressChanged(WebView view, int progress) {
            HijackActivity.this.setProgress(progress * 100);
            int fprogress = (Window.PROGRESS_END) / 100 * progress;
            setProgress(fprogress);

            if (progress == 100) {
                setProgressBarIndeterminateVisibility(false);
            }
        }
    });
}

From source file:org.esupportail.nfctagdroid.NfcTacDroidActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ESUP_NFC_TAG_SERVER_URL = getEsupNfcTagServerUrl(getApplicationContext());
    //To keep session for desfire async requests
    CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL));
    LocalStorage.getInstance(getApplicationContext());
    Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(getApplicationContext()));
    setContentView(R.layout.activity_main);
    mAdapter = NfcAdapter.getDefaultAdapter(this);
    checkHardware(mAdapter);/*from   ww w. jav  a 2 s . c  o  m*/
    localStorageDBHelper = LocalStorage.getInstance(this.getApplicationContext());
    String numeroId = localStorageDBHelper.getValue("numeroId");
    TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    String imei = telephonyManager.getDeviceId();
    url = ESUP_NFC_TAG_SERVER_URL + "/nfc-index?numeroId=" + numeroId + "&imei=" + imei + "&macAddress="
            + getMacAddr() + "&apkVersion=" + getApkVersion();
    view = (WebView) this.findViewById(R.id.webView);
    view.clearCache(true);
    view.addJavascriptInterface(new LocalStorageJavaScriptInterface(this.getApplicationContext()),
            "AndroidLocalStorage");
    view.addJavascriptInterface(new AndroidJavaScriptInterface(this.getApplicationContext()), "Android");

    view.setWebChromeClient(new WebChromeClient() {

        @Override
        public void onProgressChanged(WebView view, int progress) {
            if (progress == 100) {
                AUTH_TYPE = localStorageDBHelper.getValue("authType");
            }
        }

        @Override
        public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
            log.info("Webview console message : " + consoleMessage.message());
            return false;
        }

    });

    view.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            view.reload();
            return true;
        }
    });
    view.getSettings().setAllowContentAccess(true);
    WebSettings webSettings = view.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setDomStorageEnabled(true);
    webSettings.setDatabaseEnabled(true);
    webSettings.setDatabasePath(this.getFilesDir().getParentFile().getPath() + "/databases/");

    view.setDownloadListener(new DownloadListener() {
        public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype,
                long contentLength) {
            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setData(Uri.parse(url));
            startActivity(i);
        }

    });

    view.setWebViewClient(new WebViewClient() {
        public void onPageFinished(WebView view, String url) {
        }
    });

    view.loadUrl(url);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}

From source file:com.douban.rexxar.view.NestedWebView.java

public NestedWebView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    mChildHelper = new NestedScrollingChildHelper(this);
    setNestedScrollingEnabled(true);//from   w  w  w . j a  v  a 2  s . c o m
    final ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mTouchSlop = configuration.getScaledTouchSlop();

    WebSettings webSettings = getSettings();
    webSettings.setJavaScriptEnabled(true);
    // 
    addJavascriptInterface(new NestScrollHelper(), "Android_NestScrollHelper");
    // ?
    setOverScrollMode(OVER_SCROLL_NEVER);
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    mScroller = new OverScroller(getContext());
}

From source file:io.github.calvinmikael.anymanga.WebViewFragment.java

@SuppressLint("SetJavaScriptEnabled")
@Override/*www.j  ava  2 s . c  om*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_web_view, container, false);
    mProgressBar = (ProgressBar) view.findViewById(R.id.progressBar);
    mProgressBar.setVisibility(View.GONE);

    mWebView = (ObservableWebView) view.findViewById(R.id.webView);
    mWebView.setScrollViewCallbacks(this);
    WebSettings settings = mWebView.getSettings();

    settings.setLoadsImagesAutomatically(true);
    settings.setJavaScriptEnabled(true);
    settings.setDomStorageEnabled(true);
    mWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    settings.setBuiltInZoomControls(true);
    settings.setDisplayZoomControls(false);
    mWebView.setWebViewClient(new WebViewClient() {
        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            super.onPageStarted(view, url, favicon);
            if (!mProgressBar.isShown()) {
                mProgressBar.setVisibility(View.VISIBLE);
            }
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
            if (mProgressBar.isShown()) {
                mProgressBar.setVisibility(View.GONE);
            }
        }
    });
    mWebView.setWebChromeClient(new WebChromeClient() {
        @Override
        public void onShowCustomView(View view, CustomViewCallback callback) {
            // if a view already exists then immediately terminate the new one
            if (mCustomView != null) {
                onHideCustomView();
                return;
            }

            // Save the current state
            mCustomView = view;
            mOriginalSystemUiVisibility = getActivity().getWindow().getDecorView().getSystemUiVisibility();

            // Save the custom view callback
            mCustomViewCallback = callback;

            // Add the custom view to the view hierarchy
            FrameLayout decorView = (FrameLayout) getActivity().getWindow().getDecorView();
            decorView.addView(mCustomView, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.MATCH_PARENT));

            mTabStrip = (PagerSlidingTabStrip) getActivity().findViewById(R.id.tabs);
            mTabStrip.setVisibility(View.GONE);

            // Go fullscreen
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
                getActivity().getWindow().getDecorView()
                        .setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
            } else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT
                    && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                getActivity().getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                        | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                        | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN);
            } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                getActivity().getWindow().getDecorView()
                        .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                                | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
            }
        }

        @Override
        public void onHideCustomView() {
            // Remove the custom view
            FrameLayout decorView = (FrameLayout) getActivity().getWindow().getDecorView();
            decorView.removeView(mCustomView);
            mCustomView = null;

            mTabStrip.setVisibility(View.VISIBLE);
            // Restore the original form
            getActivity().getWindow().getDecorView().setSystemUiVisibility(mOriginalSystemUiVisibility);

            // Call the custom view callback
            mCustomViewCallback.onCustomViewHidden();
            mCustomViewCallback = null;
        }
    });
    // The back button must be handled within the mWebView for the
    // mWebView to have back behavior based on the current mPage
    // if back behavior is not handled with this listener then
    // back behavior will be entirely dependent on the first mPage
    mWebView.setOnKeyListener(new OnKeyListener() {
        @Override
        public boolean onKey(View view, int keyCode, KeyEvent keyEvent) {
            if ((keyCode == KeyEvent.KEYCODE_BACK) && mWebView.canGoBack()
                    && keyEvent.getAction() == KeyEvent.ACTION_DOWN) {
                mWebView.goBack();
                return true;
            }

            return false;
        }
    });

    if (savedInstanceState != null) {
        mWebView.restoreState(savedInstanceState);
    } else {
        if (mPage == 1) {
            mWebView.loadUrl(getString(R.string.website_kissmanga));
        } else if (mPage == 2) {
            mWebView.loadUrl(getString(R.string.website_mangapark));
        } else if (mPage == 3) {
            mWebView.loadUrl(getString(R.string.website_line_webtoon));
        }
    }

    return view;
}