List of usage examples for android.content SharedPreferences getBoolean
boolean getBoolean(String key, boolean defValue);
From source file:net.peterkuterna.android.apps.devoxxfrsched.service.CfpSyncManager.java
/** * Checks is a remote sync operation should be performed based on the fact * if we are connected to a network and if we are allowed to perform * background sync operations over mobile networks. * //w w w. jav a2 s . c o m * @param forceSync * pass true if you want to force the remote sync * @return */ public boolean shouldPerformRemoteSync(boolean forceSync) { final Context context = getContext(); final SharedPreferences prefs = Prefs.get(context); final boolean isConnectedToNetwork = NetworkUtils.isConnectedToNetwork(context); final boolean isConnectedToWifi = NetworkUtils.isConnectedToWifi(context); final boolean onlySyncOnWifi = prefs.getBoolean(SettingsActivity.KEY_AUTO_UPDATE_WIFI_ONLY, true); return (isConnectedToNetwork && (forceSync || !onlySyncOnWifi || isConnectedToWifi)); }
From source file:com.baidu.android.voicedemo.ApiActivity.java
public void bindParams(Intent intent) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); if (sp.getBoolean("tips_sound", true)) { intent.putExtra(Constant.EXTRA_SOUND_START, R.raw.bdspeech_recognition_start); intent.putExtra(Constant.EXTRA_SOUND_END, R.raw.bdspeech_speech_end); intent.putExtra(Constant.EXTRA_SOUND_SUCCESS, R.raw.bdspeech_recognition_success); intent.putExtra(Constant.EXTRA_SOUND_ERROR, R.raw.bdspeech_recognition_error); intent.putExtra(Constant.EXTRA_SOUND_CANCEL, R.raw.bdspeech_recognition_cancel); }// w w w.jav a2s . co m if (sp.contains(Constant.EXTRA_INFILE)) { String tmp = sp.getString(Constant.EXTRA_INFILE, "").replaceAll(",.*", "").trim(); intent.putExtra(Constant.EXTRA_INFILE, tmp); } if (sp.getBoolean(Constant.EXTRA_OUTFILE, false)) { intent.putExtra(Constant.EXTRA_OUTFILE, "sdcard/outfile.pcm"); } if (sp.contains(Constant.EXTRA_SAMPLE)) { String tmp = sp.getString(Constant.EXTRA_SAMPLE, "").replaceAll(",.*", "").trim(); if (null != tmp && !"".equals(tmp)) { intent.putExtra(Constant.EXTRA_SAMPLE, Integer.parseInt(tmp)); } } if (sp.contains(Constant.EXTRA_LANGUAGE)) { String tmp = sp.getString(Constant.EXTRA_LANGUAGE, "").replaceAll(",.*", "").trim(); if (null != tmp && !"".equals(tmp)) { intent.putExtra(Constant.EXTRA_LANGUAGE, tmp); } } if (sp.contains(Constant.EXTRA_NLU)) { String tmp = sp.getString(Constant.EXTRA_NLU, "").replaceAll(",.*", "").trim(); if (null != tmp && !"".equals(tmp)) { intent.putExtra(Constant.EXTRA_NLU, tmp); } } if (sp.contains(Constant.EXTRA_VAD)) { String tmp = sp.getString(Constant.EXTRA_VAD, "").replaceAll(",.*", "").trim(); if (null != tmp && !"".equals(tmp)) { intent.putExtra(Constant.EXTRA_VAD, tmp); } } String prop = null; if (sp.contains(Constant.EXTRA_PROP)) { String tmp = sp.getString(Constant.EXTRA_PROP, "").replaceAll(",.*", "").trim(); if (null != tmp && !"".equals(tmp)) { intent.putExtra(Constant.EXTRA_PROP, Integer.parseInt(tmp)); prop = tmp; } } // offline asr { intent.putExtra(Constant.EXTRA_OFFLINE_ASR_BASE_FILE_PATH, "/sdcard/easr/s_1"); intent.putExtra(Constant.EXTRA_LICENSE_FILE_PATH, "/sdcard/easr/license-tmp-20150530.txt"); if (null != prop) { int propInt = Integer.parseInt(prop); if (propInt == 10060) { intent.putExtra(Constant.EXTRA_OFFLINE_LM_RES_FILE_PATH, "/sdcard/easr/s_2_Navi"); } else if (propInt == 20000) { intent.putExtra(Constant.EXTRA_OFFLINE_LM_RES_FILE_PATH, "/sdcard/easr/s_2_InputMethod"); } } intent.putExtra(Constant.EXTRA_OFFLINE_SLOT_DATA, buildTestSlotData()); } }
From source file:uk.org.openseizuredetector.OsdUtil.java
/** * updatePrefs() - update basic settings from the SharedPreferences * - defined in res/xml/prefs.xml//from w ww.j a va2s.c o m */ public void updatePrefs() { Log.v(TAG, "updatePrefs()"); SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(mContext); try { mLogAlarms = SP.getBoolean("LogAlarms", true); Log.v(TAG, "updatePrefs() - mLogAlarms = " + mLogAlarms); mLogData = SP.getBoolean("LogData", false); Log.v(TAG, "updatePrefs() - mLogData = " + mLogData); mLogSystem = SP.getBoolean("LogSystem", true); Log.v(TAG, "updatePrefs() - mLogSystem = " + mLogSystem); } catch (Exception ex) { Log.v(TAG, "updatePrefs() - Problem parsing preferences!"); showToast( "Problem Parsing Preferences - Something won't work - Please go back to Settings and correct it!"); } }
From source file:fr.cph.chicago.activity.BaseActivity.java
/** * Connect to CTA API and get arrivals trains and buses from favorites * //from ww w . j ava 2 s.c o m * @throws ParserException * the exception */ private void loadData() throws ParserException { MultiMap<String, String> params = new MultiValueMap<String, String>(); List<Integer> favorites = Preferences.getTrainFavorites(ChicagoTracker.PREFERENCE_FAVORITES_TRAIN); for (Integer fav : favorites) { params.put("mapid", String.valueOf(fav)); } MultiMap<String, String> params2 = new MultiValueMap<String, String>(); List<String> busFavorites = Preferences.getBusFavorites(ChicagoTracker.PREFERENCE_FAVORITES_BUS); for (String str : busFavorites) { String[] fav = Util.decodeBusFavorite(str); params2.put("rt", fav[0]); params2.put("stpid", fav[1]); } // Get preferences to know if trains and buses need to be loaded SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); boolean loadTrain = true; boolean loadBus = true; if (sharedPref.contains("cta_train")) { loadTrain = sharedPref.getBoolean("cta_train", true); } else { SharedPreferences.Editor editor = sharedPref.edit(); editor.putBoolean("cta_train", true); editor.commit(); } if (sharedPref.contains("cta_bus")) { loadBus = sharedPref.getBoolean("cta_bus", true); } else { SharedPreferences.Editor editor = sharedPref.edit(); editor.putBoolean("cta_bus", true); editor.commit(); } GlobalConnectTask task = new GlobalConnectTask(this, BaseActivity.class, CtaRequestType.TRAIN_ARRIVALS, params, CtaRequestType.BUS_ARRIVALS, params2, loadTrain, loadBus, false); task.execute((Void) null); if (loadTrain) { Util.trackAction(BaseActivity.this, R.string.analytics_category_req, R.string.analytics_action_get_train, R.string.analytics_action_get_train_arrivals, 0); } if (loadBus) { Util.trackAction(BaseActivity.this, R.string.analytics_category_req, R.string.analytics_action_get_bus, R.string.analytics_action_get_bus_arrival, 0); } }
From source file:ac.robinson.mediaphone.activity.TemplateBrowserActivity.java
@Override protected void loadPreferences(SharedPreferences mediaPhoneSettings) { mAllowTemplateDeletion = mediaPhoneSettings.getBoolean(getString(R.string.key_allow_deleting_templates), getResources().getBoolean(R.bool.default_allow_deleting_templates)); }
From source file:foam.zizim.android.BoskoiService.java
public static void loadSettings(Context context) { final SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, 0); savePath = "/data/data/foam.zizim.android/files/";// settings.getString("savePath","/data/data/com.boskoi.android.app/files/"); // domain = settings.getString("Domain", ""); domain = "http://borrowed-scenery.org/zizim"; firstname = settings.getString("Firstname", ""); lastname = settings.getString("Lastname", ""); lastUpdate = settings.getString("LastUpdate", ""); lastId = settings.getLong("LastId", 0); email = settings.getString("Email", ""); countries = settings.getInt("Countries", 0); AutoUpdateDelay = settings.getInt("AutoUpdateDelay", 5); // AutoFetch = settings.getBoolean("AutoFetch", false); AutoFetch = true;/* w w w . ja va 2 s . c o m*/ totalReports = settings.getString("TotalReports", ""); smsUpdate = settings.getBoolean("SmsUpdate", false); username = settings.getString("Username", ""); password = settings.getString("Password", ""); language = settings.getString("Language", ""); lastVersion = settings.getString("LastVersion", ""); blogLastUpdate = settings.getLong("BlogLastUpdate", 0); // make sure folder exists final File dir = new File(BoskoiService.savePath); dir.mkdirs(); if (!dir.exists()) { // Log.i("SavePath ","does not exist"); try { dir.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } }
From source file:com.webkey.Ipc.java
public void notifyUpdate(Context pContext) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(pContext); if (prefs.getBoolean("statusbar", false)) notiyShow(pContext, ""); else/*from w w w. ja va 2s . c o m*/ notiyDestroy(pContext); }
From source file:com.mjhram.ttaxi.login_register.LoginActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); phpErrorMsgs = AppSettings.getInstance().getPhpErrorMsg(); inputName = (EditText) findViewById(R.id.name); inputPassword = (EditText) findViewById(R.id.password); btnLogin = (Button) findViewById(R.id.btnLogin); btnLinkToRegister = (Button) findViewById(R.id.btnLinkToRegisterScreen); setButtons(true);//from w w w .j a va 2s . co m // Progress dialog pDialog = new ProgressDialog(this); pDialog.setCancelable(false); //get GCM registeration ID: mRegistrationBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { //mRegistrationProgressBar.setVisibility(ProgressBar.GONE); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); boolean sentToken = sharedPreferences.getBoolean(Constants.SENT_TOKEN_TO_SERVER, false); /*if (sentToken) { setButtons(true); } else { setButtons(false); }*/ } }; if (checkPlayServices()) { // Start IntentService to register this application with GCM. Intent intent = new Intent(this, RegistrationIntentService.class); startService(intent); } // Session manager //session = new SessionManager(getApplicationContext()); // Check if user is already logged in or not if (AppSettings.isLoggedIn()) { // User is already logged in. Take him to main activity Intent intent = new Intent(LoginActivity.this, com.mjhram.ttaxi.GpsMainActivity.class); //intent.putExtra(Constants.KEY_UID, AppSettings.getUid()); //intent.putExtra(Constants.KEY_EMAIL, AppSettings.getEmail()); startActivity(intent); finish(); } // Login button Click Event btnLogin.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { String name = inputName.getText().toString(); String password = inputPassword.getText().toString(); //check for regId if (AppSettings.regId == null) { Toast.makeText(getApplicationContext(), getString(R.string.loginMsgNotRegistered), Toast.LENGTH_LONG).show(); finish(); } // Check for empty data in the form if (name.trim().length() > 0 && password.trim().length() > 0) { // login user checkLogin(name, password); } else { // Prompt user to enter credentials Toast.makeText(getApplicationContext(), getString(R.string.loginMsgEnterCredentials), Toast.LENGTH_LONG).show(); } } }); // Link to Register Screen btnLinkToRegister.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { Intent i = new Intent(getApplicationContext(), RegisterActivity.class); startActivity(i); finish(); } }); //registerReceiver(registrationStatusReceiver, new IntentFilter(Constants.ACTION_REGISTER)); //get registeration id //gcmUtil = new GcmUtil(getApplicationContext()); //mRegistrationProgressBar = (ProgressBar) findViewById(R.id.registrationProgressBar); //mRegistrationProgressBar.setVisibility(View.VISIBLE); }
From source file:com.irccloud.android.activity.QuickReplyActivity.java
@Override protected void onResume() { super.onResume(); SharedPreferences prefs = PreferenceManager .getDefaultSharedPreferences(IRCCloudApplication.getInstance().getApplicationContext()); prefs.registerOnSharedPreferenceChangeListener(prefslistener); nickColors = prefs.getBoolean("nick-colors", false); if (prefs.getBoolean("time-24hr", false)) { if (prefs.getBoolean("time-seconds", false)) formatter = new SimpleDateFormat("H:mm:ss"); else/* w w w . jav a 2 s . co m*/ formatter = new SimpleDateFormat("H:mm"); } else if (prefs.getBoolean("time-seconds", false)) { formatter = new SimpleDateFormat("h:mm:ss a"); } adapter.loadMessages(cid, bid); NotificationManagerCompat.from(this).cancel(bid); Notifications.getInstance().excludeBid(bid); }
From source file:org.herrlado.websms.connector.mycoolsms.Connector.java
/** * {@inheritDoc}//from w w w . j av a 2 s .c o m */ @Override public ConnectorSpec updateSpec(final Context context, final ConnectorSpec connectorSpec) { final SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(context); if (p.getBoolean(Preferences.PREFS_ENABLED, false)) { if (p.getString(Preferences.PREFS_PASSWORD, "").length() > 0) { connectorSpec.setReady(); } else { connectorSpec.setStatus(ConnectorSpec.STATUS_ENABLED); } } else { connectorSpec.setStatus(ConnectorSpec.STATUS_INACTIVE); } return connectorSpec; }