List of usage examples for android.content SharedPreferences getBoolean
boolean getBoolean(String key, boolean defValue);
From source file:com.baidu.android.voicedemo.ApiActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.sdk2_api);/*from w ww . ja v a 2s. co m*/ txtResult = (TextView) findViewById(R.id.txtResult); txtLog = (TextView) findViewById(R.id.txtLog); btn = (Button) findViewById(R.id.btn); setting = (Button) findViewById(R.id.setting); speechRecognizer = SpeechRecognizer.createSpeechRecognizer(this, new ComponentName(this, VoiceRecognitionService.class)); speechRecognizer.setRecognitionListener(this); setting.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent("com.baidu.speech.asr.demo.setting"); startActivity(intent); } }); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(ApiActivity.this); boolean api = sp.getBoolean("api", false); if (api) { switch (status) { case STATUS_None: start(); btn.setText("?"); status = STATUS_WaitingReady; break; case STATUS_WaitingReady: cancel(); status = STATUS_None; btn.setText(""); break; case STATUS_Ready: cancel(); status = STATUS_None; btn.setText(""); break; case STATUS_Speaking: stop(); status = STATUS_Recognition; btn.setText(""); break; case STATUS_Recognition: cancel(); status = STATUS_None; btn.setText(""); break; } } else { start(); } } }); }
From source file:com.google.zxing.client.android.history.HistoryManager.java
public void addHistoryItem(Result result, ResultHandler handler, String data) { // Do not save this item to the history if the preference is turned off, // or the contents are // considered secure. if (!activity.getIntent().getBooleanExtra(Intents.Scan.SAVE_HISTORY, true) || handler.areContentsSecure()) { return;/*from www . j a v a2s. c o m*/ } SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity); if (!prefs.getBoolean(PreferencesActivity.KEY_REMEMBER_DUPLICATES, false)) { deletePrevious(result.getText()); } ContentValues values = new ContentValues(); values.put(DBHelper.TEXT_COL, result.getText()); values.put(DBHelper.FORMAT_COL, result.getBarcodeFormat().toString()); values.put(DBHelper.DISPLAY_COL, handler.getDisplayContents().toString()); values.put(DBHelper.TIMESTAMP_COL, data.toString()); SQLiteOpenHelper helper = new DBHelper(activity); SQLiteDatabase db = null; try { db = helper.getWritableDatabase(); // Insert the new entry into the DB. db.insert(DBHelper.TABLE_NAME, null, values); } finally { close(null, db); } }
From source file:com.esri.UC.MainActivity.java
@Override public void onReady() { // Called when the device has registered with ArcGIS Online and is ready // to make requests to the Geotrigger Service API. //Toast.makeText(this, "GeotriggerService ready!", Toast.LENGTH_SHORT).show(); Log.d(TAG, "GeotriggerService ready!"); //check if it is the first time the app is launched, if it is do some tagging SharedPreferences settings = getSharedPreferences("MyPrefsFile", 0); if (settings.getBoolean("myfirsttime", true)) { addTag("Architecture"); addTag("Beach"); addTag("Cafe"); addTag("esrievent"); addTag("Historic Site"); addTag("Infrastructure"); addTag("Market"); addTag("Museum"); addTag("Neighborhood"); addTag("Outdoors"); addTag("Park"); addTag("Restaurant"); addTag("Sculpture"); addTag("Shopping & Dining"); addTag("Store"); settings.edit().putBoolean("myfirsttime", false).commit(); }//from w w w. j av a 2s. c o m }
From source file:com.seal.ui.components.CustomWebView.java
@SuppressLint("SetJavaScriptEnabled") public void loadSettings() { WebSettings settings = getSettings(); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); settings.setJavaScriptEnabled(prefs.getBoolean(Constants.PREFERENCE_ENABLE_JAVASCRIPT, true)); settings.setLoadsImagesAutomatically(prefs.getBoolean(Constants.PREFERENCE_ENABLE_IMAGES, true)); settings.setUseWideViewPort(prefs.getBoolean(Constants.PREFERENCE_USE_WIDE_VIEWPORT, true)); settings.setLoadWithOverviewMode(prefs.getBoolean(Constants.PREFERENCE_LOAD_WITH_OVERVIEW, false)); settings.setGeolocationEnabled(prefs.getBoolean(Constants.PREFERENCE_ENABLE_GEOLOCATION, true)); settings.setSaveFormData(prefs.getBoolean(Constants.PREFERENCE_REMEMBER_FORM_DATA, true)); settings.setSavePassword(prefs.getBoolean(Constants.PREFERENCE_REMEMBER_PASSWORDS, true)); settings.setTextZoom(prefs.getInt(Constants.PREFERENCE_TEXT_SCALING, 100)); int minimumFontSize = prefs.getInt(Constants.PREFERENCE_MINIMUM_FONT_SIZE, 1); settings.setMinimumFontSize(minimumFontSize); settings.setMinimumLogicalFontSize(minimumFontSize); settings.setUserAgentString(prefs.getString(Constants.PREFERENCE_USER_AGENT, Constants.USER_AGENT_ANDROID)); // settings.setPluginState(PluginState.valueOf(prefs.getString(Constants.PREFERENCE_PLUGINS, PluginState.ON_DEMAND.toString()))); CookieManager.getInstance().setAcceptCookie(prefs.getBoolean(Constants.PREFERENCE_ACCEPT_COOKIES, true)); settings.setSupportZoom(true);/*from w ww. ja v a 2 s. c o m*/ settings.setDisplayZoomControls(false); settings.setBuiltInZoomControls(true); settings.setSupportMultipleWindows(true); settings.setEnableSmoothTransition(true); if (mPrivateBrowsing) { settings.setGeolocationEnabled(false); settings.setSaveFormData(false); settings.setSavePassword(false); settings.setAppCacheEnabled(false); settings.setDatabaseEnabled(false); settings.setDomStorageEnabled(false); } else { // HTML5 API flags settings.setAppCacheEnabled(true); settings.setDatabaseEnabled(true); settings.setDomStorageEnabled(true); // HTML5 configuration settings. settings.setAppCacheMaxSize(3 * 1024 * 1024); settings.setAppCachePath(mContext.getDir("appcache", 0).getPath()); settings.setDatabasePath(mContext.getDir("databases", 0).getPath()); settings.setGeolocationDatabasePath(mContext.getDir("geolocation", 0).getPath()); } setLongClickable(true); setDownloadListener(this); }
From source file:com.webkey.Ipc.java
public void notiyShow(Context pContext, String message) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(pContext); if (!prefs.getBoolean("statusbar", true)) { notiyDestroy(pContext);/*w w w.j a v a 2s .c om*/ return; } Notification notification; // Log.d("Webkey","START_notify"); if (manager == null) manager = (NotificationManager) pContext.getSystemService(Context.NOTIFICATION_SERVICE); notification = new Notification(); notification.flags |= Notification.FLAG_ONGOING_EVENT; notification.icon = R.drawable.icon; //notification.tickerText = "Service is running"; notification.when = System.currentTimeMillis(); //Intent notificationIntent = new Intent(); //PendingIntent contentIntent = PendingIntent.getActivity(pContext, 0, notificationIntent, 0); //notification.setLatestEventInfo(pContext, "Webkey", "NotificationContent", contentIntent); Intent notifyIntent = new Intent(pContext, Webkey.class); notification.setLatestEventInfo(pContext, "Webkey", message, PendingIntent.getActivity(pContext, 0, notifyIntent, 0)); manager.notify(1, notification); }
From source file:com.mogoweb.ui.components.CustomWebView.java
@SuppressLint("SetJavaScriptEnabled") public void loadSettings() { WebSettings settings = getSettings(); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); settings.setJavaScriptEnabled(prefs.getBoolean(Constants.PREFERENCE_ENABLE_JAVASCRIPT, true)); settings.setLoadsImagesAutomatically(prefs.getBoolean(Constants.PREFERENCE_ENABLE_IMAGES, true)); settings.setUseWideViewPort(prefs.getBoolean(Constants.PREFERENCE_USE_WIDE_VIEWPORT, true)); settings.setLoadWithOverviewMode(prefs.getBoolean(Constants.PREFERENCE_LOAD_WITH_OVERVIEW, false)); settings.setGeolocationEnabled(prefs.getBoolean(Constants.PREFERENCE_ENABLE_GEOLOCATION, true)); settings.setSaveFormData(prefs.getBoolean(Constants.PREFERENCE_REMEMBER_FORM_DATA, true)); settings.setSavePassword(prefs.getBoolean(Constants.PREFERENCE_REMEMBER_PASSWORDS, true)); settings.setTextZoom(prefs.getInt(Constants.PREFERENCE_TEXT_SCALING, 100)); int minimumFontSize = prefs.getInt(Constants.PREFERENCE_MINIMUM_FONT_SIZE, 1); settings.setMinimumFontSize(minimumFontSize); settings.setMinimumLogicalFontSize(minimumFontSize); settings.setUserAgentString(prefs.getString(Constants.PREFERENCE_USER_AGENT, Constants.USER_AGENT_ANDROID)); // settings.setPluginState(PluginState.valueOf(prefs.getString(Constants.PREFERENCE_PLUGINS, PluginState.ON_DEMAND.toString()))); CookieManager.getInstance().setAcceptCookie(prefs.getBoolean(Constants.PREFERENCE_ACCEPT_COOKIES, true)); settings.setSupportZoom(true);//from w w w . j a v a 2 s . c o m settings.setDisplayZoomControls(false); settings.setBuiltInZoomControls(true); settings.setSupportMultipleWindows(true); settings.setEnableSmoothTransition(true); if (mPrivateBrowsing) { settings.setGeolocationEnabled(false); settings.setSaveFormData(false); settings.setSavePassword(false); settings.setAppCacheEnabled(false); settings.setDatabaseEnabled(false); settings.setDomStorageEnabled(false); } else { // HTML5 API flags settings.setAppCacheEnabled(true); settings.setDatabaseEnabled(true); settings.setDomStorageEnabled(true); // HTML5 configuration settings. settings.setAppCacheMaxSize(3 * 1024 * 1024); settings.setAppCachePath(mContext.getDir("appcache", 0).getPath()); settings.setDatabasePath(mContext.getDir("databases", 0).getPath()); settings.setGeolocationDatabasePath(mContext.getDir("geolocation", 0).getPath()); } setLongClickable(true); setDownloadListener(this); }
From source file:edu.usf.cutr.opentripplanner.android.tasks.ServerSelector.java
protected void onPreExecute() { if ((activity.get() != null) && showDialog) { progressDialog.setIndeterminate(true); progressDialog.setCancelable(true); progressDialog = ProgressDialog.show(activity.get(), "", context.getResources().getString(R.string.server_selector_progress), true); }/*from w w w.ja v a 2 s . c om*/ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); isAutoDetectEnabled = prefs.getBoolean(OTPApp.PREFERENCE_KEY_AUTO_DETECT_SERVER, true); }
From source file:com.tassadar.multirommgr.Manifest.java
public boolean downloadAndParse(Device dev, boolean check_gpg) { FileOutputStream out_man = null; FileOutputStream out_sign = null; String man_filename = MgrApp.getAppContext().getCacheDir() + "/manifest.json"; String sign_filename = MgrApp.getAppContext().getCacheDir() + "/manifest.json.asc"; try {/*w w w . jav a 2s. c o m*/ out_man = new FileOutputStream(man_filename); out_sign = new FileOutputStream(sign_filename); SharedPreferences p = MgrApp.getPreferences(); String url = dev.getDefaultManifestUrl(); if (p.getBoolean(SettingsFragment.DEV_OVERRIDE_MANIFEST, false)) url = p.getString(SettingsFragment.DEV_MANIFEST_URL, url); if (!Utils.downloadFile(url, out_man, null, true)) return false; if (dev.checkGpgSignatures() && !Utils.downloadFile(url + ".asc", out_sign, null, true)) return false; } catch (IOException e) { e.printStackTrace(); return false; } finally { Utils.close(out_man); Utils.close(out_sign); } if (check_gpg && dev.checkGpgSignatures()) { try { Gpg gpg = new Gpg(Gpg.RING_MULTIROM); if (!gpg.verifyFile(man_filename, sign_filename)) { Log.e(TAG, "Manifest signature verification failed!"); return false; } } catch (IOException e) { e.printStackTrace(); Log.e(TAG, "Manifest signature verification failed!"); return false; } } String manifest = Utils.readFile(man_filename); if (manifest == null) return false; try { Object rawObject = new JSONTokener(manifest).nextValue(); if (!(rawObject instanceof JSONObject)) { Log.e(TAG, "Malformed manifest format!"); return false; } JSONObject o = (JSONObject) rawObject; m_commands = o.optString("commands", "").split("\\|"); m_status = o.getString("status"); if (!m_status.equals("ok")) { Log.e(TAG, "MultiROM manifest's status is \"" + m_status + "\""); return false; } if (dev.checkGpgSignatures()) m_gpgData = o.optBoolean("gpg", false); JSONArray dev_array = o.getJSONArray("devices"); int device_idx = -1; int base_variant_idx = -1; for (int i = 0; i < dev_array.length(); ++i) { String name = dev_array.getJSONObject(i).getString("name"); if (name.equals(dev.getName())) { device_idx = i; break; } else if (name.equals(dev.getBaseVariantName())) { base_variant_idx = i; } } if (device_idx != -1) { o = dev_array.getJSONObject(device_idx); } else if (base_variant_idx != -1) { o = dev_array.getJSONObject(base_variant_idx); } else { return false; } JSONObject utouch = o.optJSONObject("ubuntu_touch"); if (utouch != null) { m_ubuntuReqMultiROM = utouch.getString("req_multirom"); m_ubuntuReqRecovery = utouch.getString("req_recovery"); } JSONArray changelogs = o.optJSONArray("changelogs"); if (changelogs != null) { m_changelogs = new Changelog[changelogs.length()]; for (int x = 0; x < changelogs.length(); ++x) m_changelogs[x] = new Changelog(changelogs.getJSONObject(x)); } getFileList(o.getJSONArray("files")); return true; } catch (JSONException e) { e.printStackTrace(); } return false; }
From source file:com.rothconsulting.android.websms.connector.hispeed.ConnectorHispeed.java
/** * {@inheritDoc}//from w ww. ja v a 2 s. c om */ @Override public final ConnectorSpec updateSpec(final Context context, final ConnectorSpec connectorSpec) { this.log("************************************************"); this.log("*** Start updateSpec"); this.log("************************************************"); final SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(context); if (p.getBoolean(Preferences.PREFS_ENABLED, false)) { if (p.getString(Preferences.PREFS_USER, "").length() > 0 && p.getString(Preferences.PREFS_PASSWORD, "") // . .length() > 0) { connectorSpec.setReady(); } else { connectorSpec.setStatus(ConnectorSpec.STATUS_ENABLED); } } else { connectorSpec.setStatus(ConnectorSpec.STATUS_INACTIVE); } this.log("************************************************"); this.log("*** End updateSpec"); this.log("************************************************"); return connectorSpec; }
From source file:eu.nullbyte.android.urllib.Urllib.java
public Urllib(Context context, ClientCertificate clientCert, Certificate[] pins) { mContext = context;//from w w w .j a v a 2s. c om this.headers = new HashMap<String, String>(); userAgent = createUserAgentString(); HttpParams params = new BasicHttpParams(); HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); HttpProtocolParams.setContentCharset(params, this.charset); params.setBooleanParameter("http.protocol.expect-continue", false); SchemeRegistry registry = new SchemeRegistry(); registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); boolean trustSystemKeystore = prefs.getBoolean("debug_mode", false) && prefs.getBoolean("no_cert_pinning", false); try { mSSLSocketFactory = new CertPinningSSLSocketFactory(clientCert, pins); registry.register(new Scheme("https", pins != null && !trustSystemKeystore ? mSSLSocketFactory : SSLSocketFactory.getSocketFactory(), 443)); } catch (UnrecoverableKeyException e) { e.printStackTrace(); } catch (KeyManagementException e) { e.printStackTrace(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (KeyStoreException e) { e.printStackTrace(); } ClientConnectionManager manager = new ThreadSafeClientConnManager(params, registry); httpclient = new BankdroidHttpClient(manager, params); mHttpContext = new BasicHttpContext(); }