List of usage examples for android.webkit WebSettings setDomStorageEnabled
public abstract void setDomStorageEnabled(boolean flag);
From source file:Main.java
/** * <p>Configures basic settings of the webView (Javascript enabled, DOM storage enabled, * database enabled).</p>/*w ww .ja va2 s .co m*/ * * @param webView The shared webView. */ @SuppressLint("SetJavaScriptEnabled") private static void configureWebViewDefaults(WebView webView) { WebSettings settings = webView.getSettings(); settings.setJavaScriptEnabled(true); settings.setDomStorageEnabled(true); settings.setDatabaseEnabled(true); webView.setWebChromeClient(new WebChromeClient()); }
From source file:net.niyonkuru.koodroid.webview.BlockingWebView.java
public static BlockingWebView createInstance(Context ctx) { BlockingWebView view = new BlockingWebView(ctx); WebSettings websettings = view.getSettings(); websettings.setJavaScriptEnabled(true); websettings.setDatabaseEnabled(false); websettings.setDomStorageEnabled(false); websettings.setSupportZoom(false);//from w w w. j a va2s .co m websettings.setSavePassword(false); websettings.setSupportMultipleWindows(false); websettings.setAppCacheEnabled(false); websettings.setCacheMode(WebSettings.LOAD_NO_CACHE); websettings.setBlockNetworkImage(true); return view; }
From source file:com.jio.mhood.services.api.settings.LicensesFragment.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override/*from ww w . j a v a 2 s.c o m*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup view = (ViewGroup) inflater.inflate(R.layout.fragment_licenses, container, false); if (mWebView == null) { mWebView = new WebView(view.getContext()); mWebView.setLayoutParams( new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); mWebView.setWebChromeClient(new WebChromeClient()); mWebView.setBackgroundColor(0); WebSettings webSettings = mWebView.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setDomStorageEnabled(true); webSettings.setPluginState(PluginState.ON_DEMAND); webSettings.setPluginState(PluginState.ON); webSettings.setBuiltInZoomControls(true); webSettings.setUseWideViewPort(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { webSettings.setDisplayZoomControls(false); } mWebView.loadUrl(URL); } else { mParent.removeView(mWebView); } mParent = view; mParent.addView(mWebView); return mParent; }
From source file:com.analysedesgeeks.android.WebFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { super.onCreate(savedInstanceState); final View v = inflater.inflate(R.layout.fragment_webview, container, false); webview = (WebView) v.findViewById(R.id.webview); final WebSettings settings = webview.getSettings(); settings.setJavaScriptEnabled(true); settings.setDomStorageEnabled(true); settings.setDefaultZoom(WebSettings.ZoomDensity.FAR); settings.setSupportZoom(true);/*from w w w. j ava 2 s . c o m*/ settings.setBuiltInZoomControls(true); //load a custom user agent //see http://stackoverflow.com/questions/6856814/problems-loading-mobile-twitter-in-webview settings.setUserAgentString( "Mozilla/5.0 (Linux; U; Android 2.0; en-us; Droid Build/ESD20) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17"); final View loading = v.findViewById(R.id.loading); webview.setWebViewClient(new WebViewClient() { @Override public void onPageFinished(final WebView view, final String url) { loading.setVisibility(View.GONE); } }); webview.loadUrl(url); return v; }
From source file:de.nico.asura.activities.WebView1.java
private void openWebView() { setContentView(R.layout.webview);//w ww .j a va 2 s. c o m final WebView webView = (WebView) findViewById(R.id.webView_main); WebSettings settings = webView.getSettings(); settings.setDomStorageEnabled(true); webView.setWebViewClient(new MyWebViewClient()); webView.loadUrl(getString(R.string.menu_Web_1_url)); webView.getSettings().setBuiltInZoomControls(true); webView.getSettings().setJavaScriptEnabled(getResources().getBoolean(R.bool.menu_Web_1_js)); }
From source file:de.nico.asura.activities.WebView2.java
private void openWebView() { setContentView(R.layout.webview);/*www . j a va2 s .c o m*/ final WebView webView = (WebView) findViewById(R.id.webView_main); WebSettings settings = webView.getSettings(); settings.setDomStorageEnabled(true); webView.setWebViewClient(new MyWebViewClient()); webView.loadUrl(getString(R.string.menu_Web_2_url)); webView.getSettings().setBuiltInZoomControls(true); webView.getSettings().setJavaScriptEnabled(getResources().getBoolean(R.bool.menu_Web_2_js)); }
From source file:de.nico.asura.activities.WebView3.java
private void openWebView() { setContentView(R.layout.webview);//from w w w . j a v a 2 s .c om final WebView webView = (WebView) findViewById(R.id.webView_main); WebSettings settings = webView.getSettings(); settings.setDomStorageEnabled(true); webView.setWebViewClient(new MyWebViewClient()); webView.loadUrl(getString(R.string.menu_Web_3_url)); webView.getSettings().setBuiltInZoomControls(true); webView.getSettings().setJavaScriptEnabled(getResources().getBoolean(R.bool.menu_Web_3_js)); }
From source file:com.github.snowdream.android.app.books.BookFragment.java
private void initUI(View rootview) { webView = (WebView) rootview.findViewById(R.id.webView); // progressbar = (SmoothProgressBar) rootview.findViewById(R.id.progressbar); WebSettings webSettings = webView.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setDomStorageEnabled(true); webSettings.setAllowFileAccess(true); webSettings.setSupportZoom(true);//from w ww . j a v a2s. c o m webSettings.setBuiltInZoomControls(true); webSettings.setUseWideViewPort(true); String appCachePath = getActivity().getApplicationContext().getCacheDir().getAbsolutePath(); webSettings.setAppCachePath(appCachePath); webSettings.setAppCacheEnabled(true); webView.setWebViewClient(new WebViewClient() { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { super.onPageStarted(view, url, favicon); // progressbar.setVisibility(View.VISIBLE); } @Override public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); // progressbar.setVisibility(View.INVISIBLE); } @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { super.onReceivedError(view, errorCode, description, failingUrl); // progressbar.setVisibility(View.INVISIBLE); } }); webView.setWebChromeClient(new WebChromeClient() { @Override public boolean onJsAlert(WebView view, String url, String message, JsResult result) { return super.onJsAlert(view, url, message, result); } }); // The "loadAdOnCreate" and "testDevices" XML attributes no longer available. AdView adView = (AdView) rootview.findViewById(R.id.adView); AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .addTestDevice(TEST_DEVICE_ID).build(); adView.loadAd(adRequest); getView().setFocusableInTouchMode(true); getView().setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (webView.canGoBack() && keyCode == KeyEvent.KEYCODE_BACK) { webView.goBack(); return true; } return false; } }); }
From source file:net.olejon.mdapp.MedicationNlhFragment.java
@SuppressLint("SetJavaScriptEnabled") @Override/*from www .j a v a 2s. c o m*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, final Bundle savedInstanceState) { ViewGroup viewGroup = (ViewGroup) inflater.inflate(R.layout.fragment_medication_nlh, container, false); // Activity final Activity activity = getActivity(); // Context final Context context = activity.getApplicationContext(); // Tools final MyTools mTools = new MyTools(context); // Arguments Bundle bundle = getArguments(); final String pageUri = bundle.getString("uri"); // Progress bar final ProgressBar progressBar = (ProgressBar) activity .findViewById(R.id.medication_toolbar_progressbar_horizontal); // Toolbar final LinearLayout toolbarSearchLayout = (LinearLayout) activity .findViewById(R.id.medication_toolbar_search_layout); final EditText toolbarSearchEditText = (EditText) activity.findViewById(R.id.medication_toolbar_search); // Web view WEBVIEW = (WebView) viewGroup.findViewById(R.id.medication_nlh_content); WebSettings webSettings = WEBVIEW.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setAppCacheEnabled(true); webSettings.setDomStorageEnabled(true); webSettings.setAppCachePath(context.getCacheDir().getAbsolutePath()); webSettings.setCacheMode(WebSettings.LOAD_DEFAULT); WEBVIEW.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if (!mTools.isDeviceConnected()) { mTools.showToast(getString(R.string.device_not_connected), 0); return true; } else if (url.matches(".*/[^#]+#[^/]+$")) { WEBVIEW.loadUrl(url.replaceAll("#[^/]+$", "")); return true; } else if (url.matches("^https?://.*?\\.pdf$")) { mTools.downloadFile(view.getTitle(), url); return true; } return false; } }); WEBVIEW.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int newProgress) { if (newProgress == 100) { progressBar.setVisibility(View.INVISIBLE); } else { progressBar.setVisibility(View.VISIBLE); progressBar.setProgress(newProgress); toolbarSearchLayout.setVisibility(View.GONE); toolbarSearchEditText.setText(""); } } }); if (savedInstanceState == null) { WEBVIEW.loadUrl(pageUri); } else { WEBVIEW.restoreState(savedInstanceState); } return viewGroup; }
From source file:com.btmura.android.reddit.app.LinkFragment.java
@SuppressLint("SetJavaScriptEnabled") private void setupWebView(WebView webView) { WebSettings settings = webView.getSettings(); settings.setBuiltInZoomControls(true); settings.setDisplayZoomControls(false); settings.setDomStorageEnabled(true); settings.setJavaScriptEnabled(true); settings.setLoadWithOverviewMode(true); settings.setSupportZoom(true);//from ww w.j a v a 2 s. co m settings.setPluginState(PluginState.ON_DEMAND); settings.setUseWideViewPort(true); webView.setOnLongClickListener(this); webView.setWebViewClient(new WebViewClient() { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { if (progress != null) { progress.setVisibility(View.VISIBLE); } } @Override public void onPageFinished(WebView view, String url) { if (progress != null) { progress.setVisibility(View.GONE); } } }); webView.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int newProgress) { if (progress != null) { progress.setProgress(newProgress); } } }); }