List of usage examples for android.webkit WebSettings setDatabaseEnabled
public abstract void setDatabaseEnabled(boolean flag);
From source file:com.wpi.assistments.HomeTabbedActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_webview); final ProgressDialog pd = ProgressDialog.show(this, "", "Loading...", true); isTeacher = false;// w ww. j a v a 2 s . c om toggle = true; logoutFlag = false; homeWebView = (WebView) findViewById(R.id.homeWebView); homeWebView.setWebViewClient(new WebViewClient() { public void onPageFinished(WebView view, String url) { Log.i("test", view.getUrl()); if (view.getUrl().equals("https://www.assistments.org/account/login") && !logoutFlag) { Intent intent = new Intent(getApplicationContext(), LoginActivity.class); intent.putExtra("showPopup", "true"); startActivity(intent); finish(); } else if (view.getUrl().equals("https://www.assistments.org/teacher")) { isTeacher = true; } else if (view.getUrl().equals("https://www.assistments.org/account/login") && logoutFlag) { Intent intent = new Intent(getApplicationContext(), LoginActivity.class); startActivity(intent); } if (!homeWebView.canGoBack()) { btnBack.setEnabled(false); } else { btnBack.setEnabled(true); } if (!homeWebView.canGoForward()) { btnForward.setEnabled(false); } else { btnForward.setEnabled(true); } if (pd.isShowing() && pd != null) { pd.dismiss(); } } @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { pd.show(); view.loadUrl(url); return true; } }); homeWebView.setWebChromeClient(new WebChromeClient() { @Override public boolean onJsConfirm(WebView view, String url, String message, final JsResult result) { new AlertDialog.Builder(webviewContext).setTitle("ASSISTments").setMessage(message) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { logoutFlag = true; result.confirm(); } }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { result.cancel(); } }).create().show(); return true; } }); if (savedInstanceState != null) { homeWebView.restoreState(savedInstanceState); } else { /** Scaling, replaced by overview mode and wide view port Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); if (size.x <= 780) { int scaleRate = (int) ((size.x) / 7.8); Log.i("test", Integer.toString(size.x)); homeWebView.setInitialScale(scaleRate); } */ Intent intent = getIntent(); if (intent.getStringExtra("username").equals("") && intent.getStringExtra("password").equals("")) { homeWebView.loadUrl("https://www.assistments.org/signup"); } else { String username = intent.getStringExtra("username"); String password = intent.getStringExtra("password"); String postData = "login=" + username + "&password=" + password + "&commit=Log in"; homeWebView.postUrl("https://www.assistments.org/account/login", EncodingUtils.getBytes(postData, "BASE64")); } } WebSettings settings = homeWebView.getSettings(); settings.setSaveFormData(false); settings.setSavePassword(false); settings.setJavaScriptEnabled(true); settings.setBuiltInZoomControls(true); settings.setDisplayZoomControls(false); settings.setJavaScriptCanOpenWindowsAutomatically(true); settings.setSupportMultipleWindows(true); settings.setCacheMode(WebSettings.LOAD_NO_CACHE); settings.setAppCacheEnabled(false); settings.setDomStorageEnabled(true); settings.setDatabaseEnabled(true); settings.setUseWideViewPort(false); settings.setLoadWithOverviewMode(true); homeWebView.clearCache(true); homeWebView.setPadding(0, 0, 0, 0); homeWebView.setInitialScale(getScale()); btnBack = (Button) findViewById(R.id.btnBack); btnBack.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { homeWebView.goBack(); } }); btnRefresh = (Button) findViewById(R.id.btnRefresh); btnRefresh.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //homeWebView.zoomOut(); homeWebView.scrollTo(1000, 0); Log.i("test", "111"); //homeWebView.reload(); } }); btnForward = (Button) findViewById(R.id.btnForward); btnForward.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { homeWebView.goForward(); } }); btnOffline = (Button) findViewById(R.id.btnOffline); btnOffline.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (toggle) { homeWebView.loadUrl( "https://www.assistments.org/assistments/student/index.html#offlineUserAssignmentList/"); btnOffline.setText("Home"); toggle = false; } else { if (isTeacher) { homeWebView.loadUrl("https://www.assistments.org/teacher"); } else { homeWebView.loadUrl("https://www.assistments.org/tutor"); } btnOffline.setText("Offline"); toggle = true; } } }); }
From source file:org.tomahawk.libtomahawk.resolver.ScriptResolver.java
/** * Initialize the WebView. Loads the .js script from the given path and sets the appropriate * base URL./*from w ww . j a va2 s. co m*/ * * @return the initialized WebView */ private synchronized WebView getWebView() { if (mWebView == null) { mWebView = new WebView(TomahawkApp.getContext()); WebSettings settings = mWebView.getSettings(); settings.setJavaScriptEnabled(true); settings.setDatabaseEnabled(true); settings.setDatabasePath(TomahawkApp.getContext().getDir("databases", Context.MODE_PRIVATE).getPath()); settings.setDomStorageEnabled(true); mWebView.setWebChromeClient(new TomahawkWebChromeClient()); mWebView.setWebViewClient(new ScriptWebViewClient(ScriptResolver.this)); final ScriptInterface scriptInterface = new ScriptInterface(ScriptResolver.this); mWebView.addJavascriptInterface(scriptInterface, SCRIPT_INTERFACE_NAME); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { mWebView.getSettings().setAllowUniversalAccessFromFileURLs(true); } final String baseurl = "file:///android_asset/test.html"; String data = "<!DOCTYPE html>" + "<html><body>" + "<script src=\"file:///android_asset/js/cryptojs-core.js" + "\" type=\"text/javascript\"></script>"; for (String scriptPath : mMetaData.manifest.scripts) { data += "<script src=\"file:///android_asset/" + mPath + "/" + scriptPath + "\" type=\"text/javascript\"></script>"; } try { String[] cryptoJsScripts = TomahawkApp.getContext().getAssets().list("js/cryptojs"); for (String scriptPath : cryptoJsScripts) { data += "<script src=\"file:///android_asset/js/cryptojs/" + scriptPath + "\" type=\"text/javascript\"></script>"; } } catch (IOException e) { Log.e(TAG, "ScriptResolver: " + e.getClass() + ": " + e.getLocalizedMessage()); } data += "<script src=\"file:///android_asset/js/tomahawk_android_pre.js" + "\" type=\"text/javascript\"></script>" + "<script src=\"file:///android_asset/js/tomahawk.js" + "\" type=\"text/javascript\"></script>" + "<script src=\"file:///android_asset/js/tomahawk_android_post.js" + "\" type=\"text/javascript\"></script>" + "<script src=\"file:///android_asset/" + mPath + "/" + mMetaData.manifest.main + "\" type=\"text/javascript\"></script>" + "</body></html>"; final String finalData = data; mWebView.loadDataWithBaseURL(baseurl, finalData, "text/html", null, null); } return mWebView; }
From source file:net.evecom.androidecssp.base.BaseWebActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mContext = this; temp = HttpUtil.getPageSize(this); setContentView(R.layout.message_post_web); // dialog = ProgressDialog.show(BaseWebActivity.this, null, // "..");/*from w w w . j a va2 s.c o m*/ // dialog.setCancelable(true); lineProgressBar = (ProgressBar) findViewById(R.id.webview_progress_id); imageView = (ImageView) findViewById(R.id.image_view_at_web); webView = (WebView) this.findViewById(R.id.wv_oauth_message); CookieSyncManager.createInstance(this); CookieSyncManager.getInstance().startSync(); CookieManager.getInstance().removeSessionCookie(); webView.setWebViewClient(new BaseWebViewClient((BaseWebActivity) instance)); webView.setWebChromeClient(new BaseChromeClient((BaseWebActivity) instance)); // webView.setDownloadListener(new MyWebViewDownLoadListener()); WebSettings webSettings = webView.getSettings(); webSettings.setSupportZoom(true); // WebViewJavaScript webSettings.setJavaScriptEnabled(true); webSettings.setJavaScriptCanOpenWindowsAutomatically(true); webSettings.setBuiltInZoomControls(true);// support zoom webSettings.setUseWideViewPort(true); webSettings.setLoadWithOverviewMode(true); /** */ // // webSettings.setDatabaseEnabled(true); String dir = this.getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath(); // webSettings.setGeolocationEnabled(true); // webSettings.setGeolocationDatabasePath(dir); // webSettings.setDomStorageEnabled(true); DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); int mDensity = metrics.densityDpi; if (mDensity == 240) { webSettings.setDefaultZoom(ZoomDensity.FAR); } else if (mDensity == 160) { webSettings.setDefaultZoom(ZoomDensity.MEDIUM); } else if (mDensity == 120) { webSettings.setDefaultZoom(ZoomDensity.CLOSE); // }else if(mDensity == DisplayMetrics..DENSITY_XHIGH){ // webSettings.setDefaultZoom(ZoomDensity.FAR); } else if (mDensity == DisplayMetrics.DENSITY_HIGH) { webSettings.setDefaultZoom(ZoomDensity.FAR); } dialogPress = new AlertDialog.Builder(this).setTitle("").setMessage(":0/0") .setPositiveButton("", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).create(); webView.addJavascriptInterface(new JsInterface(getApplicationContext()), "androidbase"); String url = HttpUtil.getPCURL() + "jfs/mobile/androidIndex/jqmobileTest"; // post // webView.postUrl(url, postData) postDatabyte[] // EncodingUtils.getBytes("&pwd=888", charset) webView.postUrl(url, EncodingUtils.getBytes("", "BASE64")); }
From source file:io.selendroid.server.model.SelendroidWebDriver.java
private void configureWebView(final WebView view) { ServerInstrumentation.getInstance().getCurrentActivity().runOnUiThread(new Runnable() { @Override/*ww w. ja v a 2 s. c o m*/ public void run() { try { view.clearCache(true); view.clearFormData(); view.clearHistory(); view.setFocusable(true); view.setFocusableInTouchMode(true); view.setNetworkAvailable(true); // need to check the class name rather than checking instanceof // since when it is not an instanceof, it likely means the app under test // does not contain the Cordova project and this will cause a RuntimeException if (view.getClass().getSimpleName().equalsIgnoreCase("CordovaWebView")) { CordovaWebView webview = (CordovaWebView) view; CordovaInterface ci = null; chromeClient = new ExtendedCordovaChromeClient(null, webview); } else { chromeClient = new SelendroidWebChromeClient(); } view.setWebChromeClient(chromeClient); WebSettings settings = view.getSettings(); settings.setJavaScriptCanOpenWindowsAutomatically(true); settings.setSupportMultipleWindows(true); settings.setBuiltInZoomControls(true); settings.setJavaScriptEnabled(true); settings.setAppCacheEnabled(true); settings.setAppCacheMaxSize(10 * 1024 * 1024); settings.setAppCachePath(""); settings.setDatabaseEnabled(true); settings.setDomStorageEnabled(true); settings.setGeolocationEnabled(true); settings.setSaveFormData(false); settings.setSavePassword(false); settings.setRenderPriority(WebSettings.RenderPriority.HIGH); // Flash settings settings.setPluginState(WebSettings.PluginState.ON); // Geo location settings settings.setGeolocationEnabled(true); settings.setGeolocationDatabasePath("/data/data/selendroid"); } catch (Exception e) { SelendroidLogger.error("Error configuring web view", e); } } }); }
From source file:net.evecom.android.web.Web0Activity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mContext = this; temp = HttpUtil.getPageSize(this); setContentView(R.layout.message_post_web); imageView = (ImageView) findViewById(R.id.image_view_at_web); webView = (WebView) this.findViewById(R.id.wv_oauth_message); CookieSyncManager.createInstance(this); CookieSyncManager.getInstance().startSync(); CookieManager.getInstance().removeSessionCookie(); /**/* w w w . j a va2s . c o m*/ * WebViewJavaScript */ webView.getSettings().setJavaScriptEnabled(true); /** * loadUrl() */ webView.setWebViewClient(new HelloWebViewClient()); dialog = ProgressDialog.show(Web0Activity.this, null, ".."); dialog.setCancelable(true); // http://harlan-pc/fzaj/emergency/mobileWebApp/publicInfo/login.do?userName=zf1&userPwd=1 // webView.loadUrl("http://www.baidu.com"); // String url = HttpUtil.BASE_PC_URL // String url =HttpUtil.BASE_PC_URL+"loginController/messageLogin"; String url = HttpUtil.BASE_PC_URL + "mobile/loginController/messageLogin"; // post String postDate = "loginname=" + ShareUtil.getString(getApplicationContext(), "SESSION", "USERNAME", "") + "&pwd=" + ShareUtil.getString(getApplicationContext(), "SESSION", "PASSWORD", "") + "&pageSize=" + temp; // webView.postUrl(url, postData) postDatabyte[] // EncodingUtils.getBytes(data, charset) webView.postUrl(url, EncodingUtils.getBytes(postDate, "BASE64")); // webView.setDownloadListener(new MyWebViewDownLoadListener()); WebSettings webSettings = webView.getSettings(); webSettings.setSupportZoom(true); webSettings.setJavaScriptEnabled(true); webSettings.setJavaScriptCanOpenWindowsAutomatically(true); webSettings.setBuiltInZoomControls(true);// support zoom // webSettings.setPluginsEnabled(true);//support flash webSettings.setUseWideViewPort(true); webSettings.setLoadWithOverviewMode(true); /** */ // // webSettings.setDatabaseEnabled(true); String dir = this.getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath(); // webSettings.setGeolocationEnabled(true); // webSettings.setGeolocationDatabasePath(dir); // webSettings.setDomStorageEnabled(true); // webSettings.setPluginsEnabled(true); //(flash) DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); int mDensity = metrics.densityDpi; // DebugLog.d(TAG, "densityDpi = " + mDensity); if (mDensity == 240) { webSettings.setDefaultZoom(ZoomDensity.FAR); } else if (mDensity == 160) { webSettings.setDefaultZoom(ZoomDensity.MEDIUM); } else if (mDensity == 120) { webSettings.setDefaultZoom(ZoomDensity.CLOSE); // }else if(mDensity == DisplayMetrics..DENSITY_XHIGH){ // webSettings.setDefaultZoom(ZoomDensity.FAR); } else if (mDensity == DisplayMetrics.DENSITY_HIGH) { webSettings.setDefaultZoom(ZoomDensity.FAR); } webView.setWebChromeClient(m_chromeClient);// (flash) dialogPress = new AlertDialog.Builder(this).setTitle("").setMessage(":0/0") .setPositiveButton("", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).create(); }
From source file:net.evecom.android.web.Web5Activity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mContext = this; temp = HttpUtil.getPageSize(this); setContentView(R.layout.message_post_web); imageView = (ImageView) findViewById(R.id.image_view_at_web); webView = (WebView) this.findViewById(R.id.wv_oauth_message); CookieSyncManager.createInstance(this); CookieSyncManager.getInstance().startSync(); CookieManager.getInstance().removeSessionCookie(); /**/*from w w w. ja v a 2 s. c o m*/ * WebViewJavaScript */ webView.getSettings().setJavaScriptEnabled(true); /** * loadUrl() */ webView.setWebViewClient(new HelloWebViewClient()); dialog = ProgressDialog.show(Web5Activity.this, null, ".."); dialog.setCancelable(true); // http://harlan-pc/fzaj/emergency/mobileWebApp/publicInfo/login.do?userName=zf1&userPwd=1 // webView.loadUrl("http://www.baidu.com"); // String url = HttpUtil.BASE_PC_URL // + "/buildingController/login"; http://harlan-pc/gssms/mobile/ // String url =HttpUtil.BASE_PC_URL+"/loginController/countLogin"; String url = HttpUtil.BASE_PC_URL + "mobile/loginController/countLogin"; // post // String postDate = "loginname=sysadmin&pwd=888888"; String postDate = "loginname=" + ShareUtil.getString(getApplicationContext(), "SESSION", "USERNAME", "") + "&pwd=" + ShareUtil.getString(getApplicationContext(), "SESSION", "PASSWORD", "") + "&pageSize=" + temp; // EncodingUtils.getBytes(data, charset) webView.postUrl(url, EncodingUtils.getBytes(postDate, "BASE64")); // webView.setDownloadListener(new MyWebViewDownLoadListener()); WebSettings webSettings = webView.getSettings(); webSettings.setSupportZoom(true); webSettings.setJavaScriptEnabled(true); webSettings.setJavaScriptCanOpenWindowsAutomatically(true); webSettings.setBuiltInZoomControls(true);// support zoom // webSettings.setPluginsEnabled(true);//support flash webSettings.setUseWideViewPort(true); webSettings.setLoadWithOverviewMode(true); // webSettings.setPluginsEnabled(true); //(flash) /** */ // // webSettings.setDatabaseEnabled(true); String dir = this.getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath(); // webSettings.setGeolocationEnabled(true); // webSettings.setGeolocationDatabasePath(dir); // webSettings.setDomStorageEnabled(true); DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); int mDensity = metrics.densityDpi; // DebugLog.d(TAG, "densityDpi = " + mDensity); if (mDensity == 240) { webSettings.setDefaultZoom(ZoomDensity.FAR); } else if (mDensity == 160) { webSettings.setDefaultZoom(ZoomDensity.MEDIUM); } else if (mDensity == 120) { webSettings.setDefaultZoom(ZoomDensity.CLOSE); // }else if(mDensity == DisplayMetrics..DENSITY_XHIGH){ // webSettings.setDefaultZoom(ZoomDensity.FAR); } else if (mDensity == DisplayMetrics.DENSITY_HIGH) { webSettings.setDefaultZoom(ZoomDensity.FAR); } webView.setWebChromeClient(m_chromeClient);// (flash) dialogPress = new AlertDialog.Builder(this).setTitle("").setMessage(":0/0") .setPositiveButton("", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).create(); }
From source file:net.evecom.android.web.Web4Activity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mContext = this; temp = HttpUtil.getPageSize(this); setContentView(R.layout.message_post_web); imageView = (ImageView) findViewById(R.id.image_view_at_web); webView = (WebView) this.findViewById(R.id.wv_oauth_message); CookieSyncManager.createInstance(this); CookieSyncManager.getInstance().startSync(); CookieManager.getInstance().removeSessionCookie(); /**/* ww w. j a va2 s . c om*/ * WebViewJavaScript */ webView.getSettings().setJavaScriptEnabled(true); /** * loadUrl() */ webView.setWebViewClient(new HelloWebViewClient()); dialog = ProgressDialog.show(Web4Activity.this, null, ".."); dialog.setCancelable(true); // http://harlan-pc/fzaj/emergency/mobileWebApp/publicInfo/login.do?userName=zf1&userPwd=1 // webView.loadUrl("http://www.baidu.com"); // String url = HttpUtil.BASE_PC_URL // + "/buildingController/login"; http://harlan-pc/gssms/mobile/ // String url // =HttpUtil.BASE_PC_URL+"loginController/professionalJobLogin"; String url = HttpUtil.BASE_PC_URL + "mobile/loginController/professionalJobLogin"; // post // String postDate = "loginname=sysadmin&pwd=888888"; String postDate = "loginname=" + ShareUtil.getString(getApplicationContext(), "SESSION", "USERNAME", "") + "&pwd=" + ShareUtil.getString(getApplicationContext(), "SESSION", "PASSWORD", "") + "&pageSize=" + temp; // webView.postUrl(url, postData) postDatabyte[] // EncodingUtils.getBytes(data, charset) webView.postUrl(url, EncodingUtils.getBytes(postDate, "BASE64")); // webView.setDownloadListener(new MyWebViewDownLoadListener()); WebSettings webSettings = webView.getSettings(); webSettings.setSupportZoom(true); webSettings.setJavaScriptEnabled(true); webSettings.setJavaScriptCanOpenWindowsAutomatically(true); webSettings.setBuiltInZoomControls(true);// support zoom // webSettings.setPluginsEnabled(true);//support flash webSettings.setUseWideViewPort(true); webSettings.setLoadWithOverviewMode(true); // webSettings.setPluginsEnabled(true); //(flash) /** */ // // webSettings.setDatabaseEnabled(true); String dir = this.getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath(); // webSettings.setGeolocationEnabled(true); // webSettings.setGeolocationDatabasePath(dir); // webSettings.setDomStorageEnabled(true); DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); int mDensity = metrics.densityDpi; // DebugLog.d(TAG, "densityDpi = " + mDensity); if (mDensity == 240) { webSettings.setDefaultZoom(ZoomDensity.FAR); } else if (mDensity == 160) { webSettings.setDefaultZoom(ZoomDensity.MEDIUM); } else if (mDensity == 120) { webSettings.setDefaultZoom(ZoomDensity.CLOSE); // }else if(mDensity == DisplayMetrics..DENSITY_XHIGH){ // webSettings.setDefaultZoom(ZoomDensity.FAR); } else if (mDensity == DisplayMetrics.DENSITY_HIGH) { webSettings.setDefaultZoom(ZoomDensity.FAR); } webView.setWebChromeClient(m_chromeClient);// (flash) dialogPress = new AlertDialog.Builder(this).setTitle("").setMessage(":0/0") .setPositiveButton("", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).create(); }
From source file:net.evecom.android.web.Web3Activity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mContext = this; temp = HttpUtil.getPageSize(this); setContentView(R.layout.message_post_web); imageView = (ImageView) findViewById(R.id.image_view_at_web); webView = (WebView) this.findViewById(R.id.wv_oauth_message); CookieSyncManager.createInstance(this); CookieSyncManager.getInstance().startSync(); CookieManager.getInstance().removeSessionCookie(); /**// w w w .j ava 2s . com * WebViewJavaScript */ webView.getSettings().setJavaScriptEnabled(true); /** * loadUrl() */ webView.setWebViewClient(new HelloWebViewClient()); dialog = ProgressDialog.show(Web3Activity.this, null, ".."); dialog.setCancelable(true); // http://harlan-pc/fzaj/emergency/mobileWebApp/publicInfo/login.do?userName=zf1&userPwd=1 // http://localhost/gssms/mobile/base/loginController/login?loginname=sysadmin&pwd=888888 // String url = HttpUtil.BASE_PC_URL // + "/base/loginController/login"; // http://localhost/gssms/mobile/loginController/baseLogin?loginname=sysadmin&pwd=888888 String url = HttpUtil.BASE_PC_URL + "mobile/loginController/baseLogin"; // post // String postDate = "loginname=sysadmin&pwd=888888"; String postDate = "loginname=" + ShareUtil.getString(getApplicationContext(), "SESSION", "USERNAME", "") + "&pwd=" + ShareUtil.getString(getApplicationContext(), "SESSION", "PASSWORD", "") + "&pageSize=" + temp; // webView.postUrl(url, postData) postDatabyte[] // EncodingUtils.getBytes(data, charset) webView.postUrl(url, EncodingUtils.getBytes(postDate, "BASE64")); // webView.setDownloadListener(new MyWebViewDownLoadListener()); WebSettings webSettings = webView.getSettings(); webSettings.setSupportZoom(true); webSettings.setJavaScriptEnabled(true); webSettings.setJavaScriptCanOpenWindowsAutomatically(true); webSettings.setBuiltInZoomControls(true);// support zoom // webSettings.setPluginsEnabled(true);//support flash webSettings.setUseWideViewPort(true); webSettings.setLoadWithOverviewMode(true); // webSettings.setPluginsEnabled(true); //(flash) /** */ // // webSettings.setDatabaseEnabled(true); String dir = this.getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath(); // webSettings.setGeolocationEnabled(true); // webSettings.setGeolocationDatabasePath(dir); // webSettings.setDomStorageEnabled(true); DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); int mDensity = metrics.densityDpi; // DebugLog.d(TAG, "densityDpi = " + mDensity); if (mDensity == 240) { webSettings.setDefaultZoom(ZoomDensity.FAR); } else if (mDensity == 160) { webSettings.setDefaultZoom(ZoomDensity.MEDIUM); } else if (mDensity == 120) { webSettings.setDefaultZoom(ZoomDensity.CLOSE); // }else if(mDensity == DisplayMetrics..DENSITY_XHIGH){ // webSettings.setDefaultZoom(ZoomDensity.FAR); } else if (mDensity == DisplayMetrics.DENSITY_HIGH) { webSettings.setDefaultZoom(ZoomDensity.FAR); } webView.setWebChromeClient(m_chromeClient);// (flash) dialogPress = new AlertDialog.Builder(this).setTitle("").setMessage(":0/0") .setPositiveButton("", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).create(); }
From source file:net.evecom.android.web.Web2Activity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mContext = this; temp = HttpUtil.getPageSize(this); setContentView(R.layout.message_post_web); imageView = (ImageView) findViewById(R.id.image_view_at_web); webView = (WebView) this.findViewById(R.id.wv_oauth_message); CookieSyncManager.createInstance(this); CookieSyncManager.getInstance().startSync(); CookieManager.getInstance().removeSessionCookie(); /**/*w w w .j av a 2 s.c o m*/ * WebViewJavaScript */ webView.getSettings().setJavaScriptEnabled(true); /** * loadUrl() */ webView.setWebViewClient(new HelloWebViewClient()); dialog = ProgressDialog.show(Web2Activity.this, null, ".."); dialog.setCancelable(true); // http://localhost/gssms/mobile/loginController/dailyOfficeLogin?loginname=sysadmin&pwd=888888 String url = HttpUtil.BASE_PC_URL + "mobile/loginController/dailyOfficeLogin"; // post // String postDate = "loginname=sysadmin&pwd=888888"; String postDate = "loginname=" + ShareUtil.getString(getApplicationContext(), "SESSION", "USERNAME", "") + "&pwd=" + ShareUtil.getString(getApplicationContext(), "SESSION", "PASSWORD", "") + "&pageSize=" + temp; // webView.postUrl(url, postData) postDatabyte[] // EncodingUtils.getBytes(data, charset) webView.postUrl(url, EncodingUtils.getBytes(postDate, "BASE64")); // webView.setDownloadListener(new MyWebViewDownLoadListener()); WebSettings webSettings = webView.getSettings(); webSettings.setSupportZoom(true); webSettings.setJavaScriptEnabled(true); webSettings.setJavaScriptCanOpenWindowsAutomatically(true); webSettings.setBuiltInZoomControls(true);// support zoom // webSettings.setPluginsEnabled(true);//support flash webSettings.setUseWideViewPort(true); webSettings.setLoadWithOverviewMode(true); // webSettings.setPluginsEnabled(true); //(flash) /** */ // // webSettings.setDatabaseEnabled(true); String dir = this.getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath(); // webSettings.setGeolocationEnabled(true); // webSettings.setGeolocationDatabasePath(dir); // webSettings.setDomStorageEnabled(true); DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); int mDensity = metrics.densityDpi; // DebugLog.d(TAG, "densityDpi = " + mDensity); if (mDensity == 240) { webSettings.setDefaultZoom(ZoomDensity.FAR); } else if (mDensity == 160) { webSettings.setDefaultZoom(ZoomDensity.MEDIUM); } else if (mDensity == 120) { webSettings.setDefaultZoom(ZoomDensity.CLOSE); // }else if(mDensity == DisplayMetrics..DENSITY_XHIGH){ // webSettings.setDefaultZoom(ZoomDensity.FAR); } else if (mDensity == DisplayMetrics.DENSITY_HIGH) { webSettings.setDefaultZoom(ZoomDensity.FAR); } webView.setWebChromeClient(m_chromeClient);// (flash) dialogPress = new AlertDialog.Builder(this).setTitle("").setMessage(":0/0") .setPositiveButton("", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).create(); }
From source file:com.example.administrator.mywebviewdrawsign.SysWebView.java
/** * Initialize webview./*from w w w . j ava 2 s . c o m*/ */ @SuppressLint({ "NewApi", "SetJavaScriptEnabled" }) private void setup() { this.setInitialScale(0); this.setVerticalScrollBarEnabled(true); this.setHorizontalScrollBarEnabled(true); this.requestFocusFromTouch(); // Enable JavaScript WebSettings settings = this.getSettings(); settings.setBuiltInZoomControls(false);// ?? settings.setUseWideViewPort(false); settings.setLoadWithOverviewMode(true); settings.setJavaScriptEnabled(true); settings.setJavaScriptCanOpenWindowsAutomatically(true); settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL); settings.setAllowFileAccess(true); settings.setAppCacheMaxSize(1024 * 1024 * 32); settings.setAppCachePath(mContext.getFilesDir().getPath() + "/cache"); settings.setAppCacheEnabled(true); settings.setCacheMode(WebSettings.LOAD_DEFAULT); // Set Cache Mode: LOAD_NO_CACHE is noly for debug //settings.setCacheMode(WebSettings.LOAD_NO_CACHE); //enablePageCache(settings,5); //enableWorkers(settings); // Enable database settings.setDatabaseEnabled(true); String databasePath = mContext.getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath(); settings.setDatabasePath(databasePath); // Enable DOM storage settings.setDomStorageEnabled(true); // Enable built-in geolocation settings.setGeolocationEnabled(true); // Improve render performance settings.setRenderPriority(WebSettings.RenderPriority.HIGH); if (Build.VERSION.SDK_INT >= 21) { settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); } }