private synchronized void initWebSettings() { if (android.os.Build.VERSION.SDK_INT >= 21) WebView.enableSlowWholeDocumentDraw(); WebSettings webSettings = getSettings(); userAgentOriginal = webSettings.getUserAgentString(); webSettings.setAllowContentAccess(true); webSettings.setAllowFileAccess(true); webSettings.setAllowFileAccessFromFileURLs(true); webSettings.setAllowUniversalAccessFromFileURLs(true); webSettings.setAppCacheEnabled(true); webSettings.setAppCachePath(context.getCacheDir().toString()); webSettings.setCacheMode(WebSettings.LOAD_DEFAULT); webSettings.setDatabaseEnabled(true); webSettings.setDomStorageEnabled(true); webSettings.setGeolocationDatabasePath(context.getFilesDir().toString()); webSettings.setSupportZoom(true); webSettings.setBuiltInZoomControls(true); webSettings.setDisplayZoomControls(false); webSettings.setDefaultTextEncodingName(BrowserUnit.URL_ENCODING); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { webSettings.setLoadsImagesAutomatically(true); } else { webSettings.setLoadsImagesAutomatically(false); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_hot_fashion); webview = (WebView) findViewById(R.id.webview); WebSettings s = webview.getSettings(); s.setJavaScriptEnabled(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { s.setAllowUniversalAccessFromFileURLs(true); s.setAllowFileAccessFromFileURLs(true); } webview.setWebViewClient(new WebClient()); // �������α����� ���� url ó�� WebSettings set = webview.getSettings(); set.setJavaScriptEnabled(true); webview.loadUrl("http://namjungnaedle123.cafe24.com:3000/web/hot_fashion_list"); }
// reload @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); webview = (WebView) findViewById(R.id.webview); webview.setWebViewClient(new MyWebViewClient()); // Enable JS WebSettings webSettings = webview.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setAllowFileAccessFromFileURLs(true); webSettings.setAllowUniversalAccessFromFileURLs(true); webview.setWebChromeClient(new WebChromeClient()); // Enable access to all methods in JS within WebAppInterface webview.addJavascriptInterface(new WebAppInterface(this), "FB"); webview.loadUrl("file:///android_asset/dist/index.html"); }
static void enableUniversalAccess(WebSettings settings) { settings.setAllowUniversalAccessFromFileURLs(true); }
// @TargetApi(Build.VERSION_CODES.KITKAT) @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_welcome); mWebView = (WebView) findViewById(R.id.welcomeWebView); username = (EditText) findViewById(R.id.userName); password = (EditText) findViewById(R.id.password); // welcomeTitle = (TextView)findViewById(R.id.welcomeTitle); autoSignIn(); // String htmlCode = "<h1> <a href=\"#\"> WAFFLE </a> </h1>"; // welcomeTitle.setText(Html.fromHtml(htmlCode)); // Force links and redirects to open // in the WebView instead of in a browser mWebView.setWebViewClient(new WebViewClient()); // Stop local links and redirects from // opening in browser instead of WebView mWebView.setWebViewClient(new MyAppWebViewClient()); mWebView.loadUrl(webUrl); // Enable Javascript WebSettings webSettings = mWebView.getSettings(); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) { webSettings.setAllowFileAccessFromFileURLs(true); webSettings.setAllowUniversalAccessFromFileURLs(true); webSettings.setTextZoom( webSettings.getTextZoom() + 90); // possibly creates not debuggable error } webSettings.setJavaScriptEnabled(true); // mWebView.setWebContentsDebuggingEnabled(true); mWebView.setWebChromeClient(new WebChromeClient()); // Log in button click handler Button loginButton = (Button) findViewById(R.id.loginBtt); loginButton.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { // Starts an intent of the log in activity // startActivity(new Intent(WelcomeActivity.this, LoginActivity.class)); login(); } }); // Sign up button click handler Button signupButton = (Button) findViewById(R.id.signUpBttn); signupButton.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { // Starts an intent for the sign up activity Intent intent = new Intent(WelcomeActivity.this, SignUpActivity.class); intent.putExtra("userName", username.getText().toString().trim()); intent.putExtra("password", password.getText().toString().trim()); startActivity(intent); finish(); } }); /* @Override public void onBackPressed() { if(mWebView.canGoBack()) { mWebView.goBack(); } else { super.onBackPressed(); } */ }
public TiUIWebView(TiViewProxy proxy) { super(proxy); this.isFocusable = true; TiWebView webView = isHTCSenseDevice() ? new TiWebView(proxy.getActivity()) : new NonHTCWebView(proxy.getActivity()); webView.setVerticalScrollbarOverlay(true); WebSettings settings = webView.getSettings(); settings.setUseWideViewPort(true); settings.setJavaScriptEnabled(true); settings.setSupportMultipleWindows(true); settings.setJavaScriptCanOpenWindowsAutomatically(true); settings.setAllowFileAccess(true); settings.setDomStorageEnabled( true); // Required by some sites such as Twitter. This is in our iOS WebView too. File path = TiApplication.getInstance().getFilesDir(); if (path != null) { settings.setDatabasePath(path.getAbsolutePath()); settings.setDatabaseEnabled(true); } File cacheDir = TiApplication.getInstance().getCacheDir(); if (cacheDir != null) { settings.setAppCacheEnabled(true); settings.setAppCachePath(cacheDir.getAbsolutePath()); } // enable zoom controls by default boolean enableZoom = true; if (proxy.hasProperty(TiC.PROPERTY_ENABLE_ZOOM_CONTROLS)) { enableZoom = TiConvert.toBoolean(proxy.getProperty(TiC.PROPERTY_ENABLE_ZOOM_CONTROLS)); } settings.setBuiltInZoomControls(enableZoom); settings.setSupportZoom(enableZoom); if (TiC.JELLY_BEAN_OR_GREATER) { settings.setAllowUniversalAccessFromFileURLs( true); // default is "false" for JellyBean, TIMOB-13065 } // We can only support webview settings for plugin/flash in API 8 and higher. if (Build.VERSION.SDK_INT > Build.VERSION_CODES.ECLAIR_MR1) { initializePluginAPI(webView); } boolean enableJavascriptInterface = TiConvert.toBoolean(proxy.getProperty(TiC.PROPERTY_ENABLE_JAVASCRIPT_INTERFACE), true); chromeClient = new TiWebChromeClient(this); webView.setWebChromeClient(chromeClient); client = new TiWebViewClient(this, webView); webView.setWebViewClient(client); if (Build.VERSION.SDK_INT > 16 || enableJavascriptInterface) { client.getBinding().addJavascriptInterfaces(); } webView.client = client; if (proxy instanceof WebViewProxy) { WebViewProxy webProxy = (WebViewProxy) proxy; String username = webProxy.getBasicAuthenticationUserName(); String password = webProxy.getBasicAuthenticationPassword(); if (username != null && password != null) { setBasicAuthentication(username, password); } webProxy.clearBasicAuthentication(); } TiCompositeLayout.LayoutParams params = getLayoutParams(); params.autoFillsHeight = true; params.autoFillsWidth = true; setNativeView(webView); }
@SuppressLint("SetJavaScriptEnabled") @TargetApi(Build.VERSION_CODES.JELLY_BEAN) @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); try { // get url and navigatio preference (default true) final String url = getIntent().getStringExtra(getPackageName() + ".URL"); final boolean navigation = getIntent().getBooleanExtra(getPackageName() + ".NAVIGATION", true); setContentView(R.layout.webviewnav); // if we want navigation bar and not hide it, make it visible. Make it invisible if not. if (navigation && !hideNavigationBar) { findViewById(R.id.webBottomBar).setVisibility(View.VISIBLE); } else { findViewById(R.id.webBottomBar).setVisibility(View.GONE); } mButtonBack = (ImageButton) findViewById(R.id.buttonWebBack); mButtonForward = (ImageButton) findViewById(R.id.buttonWebForward); mButtonStop = (ImageButton) findViewById(R.id.buttonWebStop); mProgressView = (ProgressBar) findViewById(R.id.progressBar); mProgressView.setIndeterminate(true); // init webview mWebView = (WebView) findViewById(R.id.webView); // disable hw accel as it creates flickering pages, html5 video won't work with this if (Build.VERSION.SDK_INT >= 11 && Build.VERSION.SDK_INT < 16) mWebView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); // This hides white bar on the right mWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); WebSettings settings = mWebView.getSettings(); // enable plugins before java script settings.setPluginState(PluginState.ON); // TODO test these two settings with a big webpage (cafe lotty?) settings.setLoadWithOverviewMode(true); settings.setUseWideViewPort(true); // enable javascript and zoom controls settings.setJavaScriptEnabled(true); settings.setBuiltInZoomControls(true); settings.setGeolocationEnabled(true); settings.setDatabaseEnabled(true); String databasePath = getDir("database_ext", Context.MODE_PRIVATE).getPath(); settings.setDatabasePath(databasePath); settings.setGeolocationDatabasePath(databasePath); settings.setDomStorageEnabled(true); settings.setAppCacheEnabled(true); // allow XMLHttpRequests if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) settings.setAllowUniversalAccessFromFileURLs(true); MetaioWebViewClient client = new MetaioWebViewClient(); mWebView.setWebViewClient(client); mWebView.setWebChromeClient(new MetaioWebChromeClient()); registerForContextMenu(mWebView); if (savedInstanceState != null) { mWebView.restoreState(savedInstanceState); } else { // if we don't have to override the url, load it in the webview if (!client.shouldOverrideUrlLoading(mWebView, url)) mWebView.loadUrl(url); } } catch (Exception e) { MetaioCloudPlugin.log(Log.ERROR, "WebViewActivity.onCreate", e); } }