List of usage examples for android.webkit WebSettings setJavaScriptEnabled
public abstract void setJavaScriptEnabled(boolean flag);
From source file:it.clipart.swipehtmlpageapp.IntroFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { rootView = inflater.inflate(R.layout.intro_screen, container, false); View controlView = rootView.findViewById(R.id.introFinishControls); /*//from ww w. j av a 2s . c o m If we are on the last page of the intro, we show a special controlView that lets the user select if they ever want to see this again, and continue on to the main part of the app. Se si nell'ultima pagina dell'intro, verr mostrato uno speciale controlView che lascia l'utente se vuole vederlo da capo o proseguire nella parte principale. */ if (item == MyWebActivity.NUM_INTRO_PAGES) { /* Se l'ultima pagina rende visibile il layout contenente il controllo che lancia la guida vera e propria - Il fatto che sia l'ultima pagina non viene creato un successivo Fragment e quindi lo swipe non pi attivo. */ controlView.setVisibility(View.VISIBLE); // Controlla la checkBox "Non mostrare pi" rootView.findViewById(R.id.checkBox).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { dontShowAgainTapped(); } }); } // Se si torna indietro ( ad esempio ) rende invisibile il controllo di cui sopra else { controlView.setVisibility(View.INVISIBLE); } WebView webview = (WebView) rootView.findViewById(R.id.webView); android.webkit.WebSettings webSettings = webview.getSettings(); webSettings.setJavaScriptEnabled(true); webview.getSettings().setLoadsImagesAutomatically(true); webview.addJavascriptInterface(new WebAppInterface(this.activity), "Android"); webview.loadUrl("file:///android_asset/intro" + item + ".html"); Log.d(TAG, "Caricata la pagina intro url: " + webview.getUrl()); return rootView; }
From source file:jlelse.simplewebwrapper.SimpleWebWrapperActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // FAB//www. java 2s. com enableFabChanges(); //WebView webView = new WebView(this); WebSettings webSettings = webView.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setAppCacheEnabled(true); webView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if (isOnlyOwnPagesAllowed()) { if (Uri.parse(url).getHost().equals(Uri.parse(getStartUrl()).getHost())) { loadUrl(url); return false; } Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity(intent); return true; } else { return false; } } @Override public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { handler.proceed(); } }); addContentView(webView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); }
From source file:com.sparkplatform.ui.WebViewActivity.java
@SuppressLint("SetJavaScriptEnabled") @Override/*from www. j ava2 s. c o m*/ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_web_view); this.sparkClient = SparkAPI.getInstance(); Intent intent = getIntent(); loginHybrid = intent.getBooleanExtra(UIConstants.EXTRA_LOGIN_HYBRID, true); WebView webView = (WebView) findViewById(R.id.webview); WebSettings webSettings = webView.getSettings(); webSettings.setJavaScriptEnabled(true); webView.setWebViewClient(new SparkWebViewClient()); webView.loadUrl(SparkAPI.sparkOpenIdLogoutURL); }
From source file:com.rizal.lovins.smartkasir.activity.SettingsActivity.java
@SuppressLint("SetJavaScriptEnabled") @Override//from w w w. j a v a 2s. c o m protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_settings); toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); setTitle("Settings"); WebView mWebView = (WebView) findViewById(R.id.webView); WebSettings webSettings = mWebView.getSettings(); webSettings.setJavaScriptEnabled(true); mWebView.getSettings().setBuiltInZoomControls(false); mWebView.getSettings().setDisplayZoomControls(false); mWebView.loadUrl("file:///android_asset/license/settings.html"); CustomGridViewSettingAdapter adapterViewAndroid = new CustomGridViewSettingAdapter(SettingsActivity.this, gridViewString, gridViewImageId); androidGridView = (GridView) findViewById(R.id.grid_view_image_text); androidGridView.setAdapter(adapterViewAndroid); androidGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { switch (position) { case 0: startActivity(new Intent(SettingsActivity.this, AboutActivity.class)); break; case 1: startActivity(new Intent(SettingsActivity.this, DeveloperActivity.class)); break; case 2: startActivity(new Intent(SettingsActivity.this, LicenseActivity.class)); break; case 3: startActivity(new Intent(SettingsActivity.this, MapsActivity.class)); break; case 4: location(); break; } } }); }
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);/*w w w . j av a 2 s.com*/ 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:org.catnut.fragment.OAuthFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // clear cache WebSettings settings = mWebView.getSettings(); settings.setJavaScriptEnabled(true); settings.setCacheMode(WebSettings.LOAD_NO_CACHE); settings.setSaveFormData(false);/*from www. j a v a 2 s . co m*/ mWebView.loadUrl(Manifest.getOAuthUri()); }
From source file:com.nestlabs.sdk.NestAuthActivity.java
@Override @SuppressLint("SetJavaScriptEnabled") protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.nest_auth_webview_layout); WebView clientWebView = (WebView) findViewById(R.id.auth_webview); mProgressBar = (ProgressBar) findViewById(R.id.webview_progress); mNestConfig = getIntent().getParcelableExtra(KEY_CLIENT_METADATA); // If any args are empty, they are invalid and we should finish. if (mNestConfig == null || Utils.isAnyEmpty(mNestConfig.getRedirectURL(), mNestConfig.getClientID(), mNestConfig.getStateValue())) { finishWithResult(RESULT_CANCELED, null); return;/*from w ww. j av a2 s . c o m*/ } mHttpClient = new OkHttpClient(); clientWebView.setWebChromeClient(new ProgressChromeClient()); clientWebView.setWebViewClient(new RedirectClient()); String url = String.format(NestAPI.CLIENT_CODE_URL, mNestConfig.getClientID(), mNestConfig.getStateValue()); WebSettings webSettings = clientWebView.getSettings(); webSettings.setJavaScriptEnabled(true); clientWebView.loadUrl(url); }
From source file:org.schabi.newpipe.ReCaptchaActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_recaptcha); // Set return to Cancel by default setResult(RESULT_CANCELED);// w ww . j av a 2s . c o m Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setTitle(R.string.reCaptcha_title); actionBar.setDisplayShowTitleEnabled(true); } WebView myWebView = (WebView) findViewById(R.id.reCaptchaWebView); // Enable Javascript WebSettings webSettings = myWebView.getSettings(); webSettings.setJavaScriptEnabled(true); ReCaptchaWebViewClient webClient = new ReCaptchaWebViewClient(this); myWebView.setWebViewClient(webClient); // Cleaning cache, history and cookies from webView myWebView.clearCache(true); myWebView.clearHistory(); android.webkit.CookieManager cookieManager = CookieManager.getInstance(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { cookieManager.removeAllCookies(new ValueCallback<Boolean>() { @Override public void onReceiveValue(Boolean aBoolean) { } }); } else { cookieManager.removeAllCookie(); } myWebView.loadUrl(YT_URL); }
From source file:com.amanmehara.programming.android.adapters.DetailAdapter.java
@SuppressLint("SetJavaScriptEnabled") @Override//from w ww . j ava 2s. c o m public void onBindViewHolder(ViewHolder viewHolder, int i) { WebSettings webSettings = viewHolder.fileContentView.getSettings(); webSettings.setJavaScriptEnabled(true); try { JSONObject jsonObject = programContents.getJSONObject(i); viewHolder.fileNameView.setText(jsonObject.getString("name")); String url = jsonObject.getString("url"); String response = sharedPreferences.getString(url, null); if (Objects.nonNull(response)) { getContentResponseCallback(url, true, viewHolder).accept(response); } else { new GithubAPIClient(activity, getContentResponseCallback(url, false, viewHolder)) .execute(withAccessToken(url)); } } catch (JSONException e) { Log.e(TAG, e.getMessage()); } }
From source file:de.zell.android.util.fragments.WebviewFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_webview, container, false); if (url != null && !url.isEmpty()) { content = ((WebView) rootView.findViewById(R.id.webview)); //WebViewClient is enabled in order to force all links to load within the webview and also // in order to enable JavaScript content.setWebViewClient(new HelloWebViewClient()); WebSettings webSettings = content.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setBuiltInZoomControls(true); webSettings.setSupportZoom(true); final ProgressBar progressBar = ((MainNavigationActivity) getActivity()).getProgressBar(); content.setWebChromeClient(new WebChromeClient() { @Override//from w w w .j a v a 2s .co m public void onProgressChanged(WebView view, int newProgress) { progressBar.setProgress(newProgress); if (newProgress == 100) progressBar.setVisibility(View.GONE); } }); progressBar.setIndeterminate(true); progressBar.setVisibility(View.VISIBLE); content.loadUrl(url); } getActivity().setTitle(title); return rootView; }