public void onClick(View v) { switch (v.getId()) { case R.id.go_local: // 标记为本地媒体 // editor.putBoolean("isLiveMedia", false); // 暂时去掉本地媒体播放,所以这里仍然设置为直播电视 editor.putBoolean("isLiveMedia", true); editor.commit(); startLocalMedia(); break; case R.id.go_live: // 标记为直播电视媒体 editor.putBoolean("isLiveMedia", true); editor.commit(); startLiveMedia(); break; case R.id.go_userdef: startUserLoadMedia(); break; case R.id.go_setup: startSetupMedia(); break; default: Log.d(LOGTAG, "not supported btn id"); } }
void updatePreferences() { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ApplicationScreen.getMainContext()); mGyroState = prefs.getBoolean("PrefGyroVF", false); if (!prefs.contains("PrefGyroTypeVF")) { Editor editor = prefs.edit(); if (mGyroscope != null) { editor.putBoolean("PrefGyroTypeVF", true); } else { editor.putBoolean("PrefGyroTypeVF", false); } editor.commit(); } mPrefHardwareGyroscope = prefs.getBoolean("PrefGyroTypeVF", false); if (mGyroState == ON) { CameraController.setNeedPreviewFrame(true); quickControlIconID = R.drawable.gui_almalence_settings_gyro; if (mHorizonIndicatorContainer != null) { mHorizonIndicatorContainer.setVisibility(View.VISIBLE); } initSensors(); } else { quickControlIconID = R.drawable.gui_almalence_settings_gyro_off; if (mHorizonIndicatorContainer != null) { mHorizonIndicatorContainer.setVisibility(View.GONE); } releaseSensors(); } }
/** Save current audio mode in order to be able to restore it once done */ @SuppressWarnings("deprecation") private synchronized void saveAudioState() { if (prefs.getBoolean("isSavedAudioState", false)) { // If we have already set, do not set it again !!! return; } ContentResolver ctntResolver = service.getContentResolver(); Editor ed = prefs.edit(); // ed.putInt("savedVibrateRing", // audioManager.getVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER)); // ed.putInt("savedVibradeNotif", // audioManager.getVibrateSetting(AudioManager.VIBRATE_TYPE_NOTIFICATION)); // ed.putInt("savedRingerMode", audioManager.getRingerMode()); ed.putInt( "savedWifiPolicy", android.provider.Settings.System.getInt( ctntResolver, android.provider.Settings.System.WIFI_SLEEP_POLICY, Settings.System.WIFI_SLEEP_POLICY_DEFAULT)); int inCallStream = Compatibility.getInCallStream(userWantBluetooth); ed.putInt("savedVolume", audioManager.getStreamVolume(inCallStream)); int targetMode = getAudioTargetMode(); if (service.getPrefs().useRoutingApi()) { ed.putInt("savedRoute", audioManager.getRouting(targetMode)); } else { ed.putBoolean("savedSpeakerPhone", audioManager.isSpeakerphoneOn()); } ed.putInt("savedMode", audioManager.getMode()); ed.putBoolean("isSavedAudioState", true); ed.commit(); }
/** Listener for the On/Off switch */ @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { if (key.equals(ONOFF_KEY)) { running = !running; Editor editor = sharedPreferences.edit(); editor.putBoolean(IS_ON, running); editor.commit(); if (running) { if (runNormal) SensorPreferenceActivity.start(SensorPreferenceActivity.this.getApplicationContext()); else SensorPreferenceActivity.startLite(SensorPreferenceActivity.this.getApplicationContext()); } else { if (runNormal) SensorPreferenceActivity.stop(SensorPreferenceActivity.this.getApplicationContext()); else SensorPreferenceActivity.stopLite(SensorPreferenceActivity.this.getApplicationContext()); } } if (key.equals(ANALYTIC_KEY)) { runNormal = !runNormal; Editor editor = sharedPreferences.edit(); editor.putBoolean(ANALYTIC_ON, runNormal); editor.commit(); if (running) { if (runNormal) { SensorPreferenceActivity.stopLite(SensorPreferenceActivity.this.getApplicationContext()); SensorPreferenceActivity.start(SensorPreferenceActivity.this.getApplicationContext()); } else { SensorPreferenceActivity.stop(SensorPreferenceActivity.this.getApplicationContext()); SensorPreferenceActivity.startLite(SensorPreferenceActivity.this.getApplicationContext()); } } } }
public static void setBoolean(String key, boolean value, boolean isPublic) { if (isPublic) { mEditor.putBoolean(key, value); } else { mEditor.putBoolean(userId() + key, value); } mEditor.commit(); }
private boolean loadSharedPreferencesFromFile(File src) { // this should probably be in a thread if it ever gets big boolean res = false; ObjectInputStream input = null; try { input = new ObjectInputStream(new FileInputStream(src)); Editor prefEdit = PreferenceManager.getDefaultSharedPreferences(this).edit(); prefEdit.clear(); // first object is preferences Map<String, ?> entries = (Map<String, ?>) input.readObject(); for (Entry<String, ?> entry : entries.entrySet()) { Object v = entry.getValue(); String key = entry.getKey(); if (v instanceof Boolean) prefEdit.putBoolean(key, ((Boolean) v).booleanValue()); else if (v instanceof Float) prefEdit.putFloat(key, ((Float) v).floatValue()); else if (v instanceof Integer) prefEdit.putInt(key, ((Integer) v).intValue()); else if (v instanceof Long) prefEdit.putLong(key, ((Long) v).longValue()); else if (v instanceof String) prefEdit.putString(key, ((String) v)); } prefEdit.commit(); // second object is admin options Editor adminEdit = getSharedPreferences(AdminPreferencesActivity.ADMIN_PREFERENCES, 0).edit(); adminEdit.clear(); // first object is preferences Map<String, ?> adminEntries = (Map<String, ?>) input.readObject(); for (Entry<String, ?> entry : adminEntries.entrySet()) { Object v = entry.getValue(); String key = entry.getKey(); if (v instanceof Boolean) adminEdit.putBoolean(key, ((Boolean) v).booleanValue()); else if (v instanceof Float) adminEdit.putFloat(key, ((Float) v).floatValue()); else if (v instanceof Integer) adminEdit.putInt(key, ((Integer) v).intValue()); else if (v instanceof Long) adminEdit.putLong(key, ((Long) v).longValue()); else if (v instanceof String) adminEdit.putString(key, ((String) v)); } adminEdit.commit(); res = true; } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } finally { try { if (input != null) { input.close(); } } catch (IOException ex) { ex.printStackTrace(); } } return res; }
private void SaveUser() { SharedPreferences sp = getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE); Editor spEd = sp.edit(); if (check.isChecked()) { spEd.putBoolean("isSave", true); spEd.putString("username", nameText.getText().toString()); } else { spEd.putBoolean("isSave", false); spEd.putString("username", ""); } spEd.commit(); }
public void onClick(View v) { int id = v.getId(); if (id == R.id.ToggleButtonBoldText) { if ((tb_bold).isChecked()) { textView1.setTypeface(typefaceBold); textView2.setTypeface(typefaceBold); brtn1.setTypeface(typefaceBold); btn_textSize.setTypeface(typefaceBold); btn_textBold.setTypeface(typefaceBold); Button01.setTypeface(typefaceBold); Editor editor = mSettings.edit(); editor.putBoolean(APP_PREFERENCES_bold_text, true); editor.apply(); } else { textView1.setTypeface(typefaceRoman); textView2.setTypeface(typefaceRoman); brtn1.setTypeface(typefaceRoman); btn_textSize.setTypeface(typefaceRoman); btn_textBold.setTypeface(typefaceRoman); Button01.setTypeface(typefaceRoman); Editor editor = mSettings.edit(); editor.putBoolean(APP_PREFERENCES_bold_text, false); editor.apply(); } } else if (id == R.id.brtntoggle) { if ((tb_brtns).isChecked()) { Settings.System.putInt( getContentResolver(), SCREEN_BRIGHTNESS_MODE, SCREEN_BRIGHTNESS_MODE_AUTOMATIC); refreshBrightness(-1); } else { Settings.System.putInt( getContentResolver(), SCREEN_BRIGHTNESS_MODE, SCREEN_BRIGHTNESS_MODE_MANUAL); refreshBrightness(-1); } } else if (id == R.id.Button04) { Intent settingsIntent = new Intent(android.provider.Settings.ACTION_DISPLAY_SETTINGS); startActivity(settingsIntent); overridePendingTransition(center_to_left, center_to_left2); } else if (id == R.id.ButtonTextSize) { Intent intent18 = new Intent(this, ActivityTextSize.class); startActivity(intent18); overridePendingTransition(center_to_right, center_to_right2); } else if (id == R.id.Button01) { speed_anim(); } }
private void writeToFile() { try { SharedPreferences preferencias = getSharedPreferences("datos", Context.MODE_PRIVATE); Editor editor = preferencias.edit(); editor.putBoolean("isPositionActive", Config.isPositionActive); editor.putBoolean("isActive", Config.isSmsActive); editor.putString("code", Config.code); editor.commit(); Toast.makeText(getApplicationContext(), "Se Guardó la configuración", Toast.LENGTH_LONG) .show(); } catch (Exception e) { System.out.println("Error: " + e.getLocalizedMessage()); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_start); SharedPreferences preferences = this.getSharedPreferences("sp_LoveShare", MODE_PRIVATE); boolean isStarted = preferences.getBoolean("isStarted", false); final boolean isStarted1 = isStarted; Editor editor = preferences.edit(); // 如果是SharedPreferences中的isStarted为false,即用户第一次打开程序,则将isStarted设为true // 并且默认有提示音和手机振动的效果 if (!isStarted) { createDeskShortCut(); editor.putBoolean("isStarted", true); editor.putBoolean("isSounds", true); editor.putBoolean("isVibration", true); editor.putString( "savePath", Environment.getExternalStorageDirectory().getAbsolutePath() + this.getString(R.string.imgPath)); editor.putInt("theme", R.drawable.background_winter); // 设置默认背景 editor.commit(); } new Handler() .postDelayed( new Runnable() { @Override public void run() { Intent intent = new Intent(); if (!isStarted1) intent.setClass(StartActivity.this, WelcomeActivity.class); else intent.setClass(StartActivity.this, MainActivity.class); StartActivity.this.startActivity(intent); StartActivity.this.overridePendingTransition(R.anim.alpha_enter, R.anim.alpha_exit); // 由于此界面不需要回退,所以跳转完立刻将其finish StartActivity.this.finish(); } }, 300); /* * dialog = new ProgressDialog(this); * dialog.setIcon(R.drawable.ic_launcher); * dialog.setMessage("please wait……"); */ }
public void viewSwitcher(View v) { Editor editor = categoryViewShared.edit(); if (myAdapter.getViewType() == MyAdapter.LAYOUT_ITEM_GRID) { recyclerView.setLayoutManager(new LinearLayoutManager(this)); viewSwticherImageView.setImageDrawable(getResources().getDrawable(R.drawable.ic_grid)); myAdapter.setType(MyAdapter.LAYOUT_ITEM_LIST); editor.putBoolean("isGridView", false); } else { recyclerView.setLayoutManager(new GridLayoutManager(this, 2)); myAdapter.setType(MyAdapter.LAYOUT_ITEM_GRID); viewSwticherImageView.setImageDrawable(getResources().getDrawable(R.drawable.ic_list)); editor.putBoolean("isGridView", true); } editor.commit(); }
protected void setupSIP(Context context, SIP5060ProvisioningRequest req) throws IOException { AppProperties props = new AppProperties(context); // Setup the SIP preferences SharedPreferences settings = context.getSharedPreferences(RegisterAccount.PREFS_FILE, Context.MODE_PRIVATE); SharedPreferences sipSettings = context.getSharedPreferences(Settings.sharedPrefsFile, Context.MODE_PRIVATE); Editor edSIP = sipSettings.edit(); String num = req.getPhoneNumber(); LumicallDataSource ds = new LumicallDataSource(context); ds.open(); SIPIdentity sipIdentity = createSIPIdentity(props, settings, req); for (SIPIdentity s : ds.getSIPIdentities()) { if (s.getUri().equals(sipIdentity.getUri())) sipIdentity.setId(s.getId()); } ds.persistSIPIdentity(sipIdentity); ds.deleteSIP5060ProvisioningRequest(req); ds.close(); edSIP.putString(Settings.PREF_SIP, Long.toString(sipIdentity.getId())); if (!sipSettings.contains(Settings.PREF_TEL)) edSIP.putString(Settings.PREF_TEL, "-1"); /* edSIP.putString(Settings.PREF_USERNAME, settings.getString(RegisterAccount.PREF_PHONE_NUMBER, null)); edSIP.putString(Settings.PREF_PASSWORD, settings.getString(RegisterAccount.PREF_SECRET, null)); edSIP.putString(Settings.PREF_SERVER, DEFAULT_SIP_SERVER); edSIP.putString(Settings.PREF_DOMAIN, DEFAULT_SIP_DOMAIN); edSIP.putString(Settings.PREF_PROTOCOL, "tcp"); // FIXME - change to TLS edSIP.putBoolean(Settings.PREF_STUN, true); edSIP.putString(Settings.PREF_STUN_SERVER, DEFAULT_STUN_SERVER); edSIP.putString(Settings.PREF_STUN_SERVER_PORT, "" + DEFAULT_STUN_SERVER_PORT); */ edSIP.putBoolean(Settings.PREF_WLAN, true); edSIP.putBoolean(Settings.PREF_EDGE, true); edSIP.putBoolean(Settings.PREF_3G, true); edSIP.putBoolean(Settings.PREF_ON, true); if (edSIP.commit()) Log.v(TAG, "Configured prefs for number " + num); else { Log.e(TAG, "error while committing preferences"); } // Receiver.engine(context).updateDNS(); Receiver.engine(context).halt(); Receiver.engine(context).StartEngine(); }
@Override public void onClick(View v) { // TODO Auto-generated method stub switch (v.getId()) { case R.id.iv_setting_leftarrow: finish(); break; case R.id.rl_setting_version: progressDialog.show(); new Thread(r_CheckNewVersion).start(); break; case R.id.rl_setting_storage: File file = new File(Environment.getExternalStorageDirectory() + "/CourtPocket"); if (file.exists()) { File flist[] = file.listFiles(); for (int i = 0; i < flist.length; i++) { flist[i].delete(); } tv_storage.setText("0KB"); } break; case R.id.rl_setting_notification: SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(SettingActivity.this); Boolean isNotificationOpen = prefs.getBoolean("isNotificationOpen", true); if (isNotificationOpen) { tv_notification.setText("关闭"); Editor pEdit = prefs.edit(); pEdit.putBoolean("isNotificationOpen", false); pEdit.commit(); } else { tv_notification.setText("打开"); Editor pEdit = prefs.edit(); pEdit.putBoolean("isNotificationOpen", true); pEdit.commit(); } break; case R.id.btn_setting_quitlogin: Data.ISLOGIN = false; // 帐号反注册信鸽推送 XGPushManager.registerPush(SettingActivity.this, "*"); setResult(RESULT_OK, SettingActivity.this.getIntent()); finish(); break; } }
/** Create login session */ public void createLocationsSession(String locations) { editor.putBoolean(IS_LOADED, true); editor.putString(KEY_LOCATIONS, locations); // commit changes editor.commit(); }
/** * 写入布尔型数据 * * @param context 上下文 * @param key 键 * @param value 值 */ public static void writeBoolean(Context context, String key, Boolean value) { SharedPreferences preference = context.getSharedPreferences(AppConstant.SHARPREFER_FILENAME, Context.MODE_PRIVATE); Editor editor = preference.edit(); editor.putBoolean(key, value); editor.commit(); }
public static void savePreferences(Activity activity, String key, boolean value) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(activity.getApplicationContext()); Editor editor = sp.edit(); editor.putBoolean(key, value); editor.commit(); }
/** * Starts a new clock in with an offset if boolean is true, otherwise uses the current system * time. The offset is X minutes, IE closest 15 minutes or 30, chosen by the user under settings. * * @param boolean to start new clock in with user set offset. */ protected void startNewClock(boolean offset) { Calendar cal = Calendar.getInstance(); if (offset) { cal = roundCalendar(cal); } String DATE_FORMAT = "dd/MM/yyyy HH:mm"; if (sp.getBoolean("prefs_time_24", true)) { DATE_FORMAT = "dd/MM/yyyy HH:mm"; } else { DATE_FORMAT = "dd/MM/yyyy hh:mm a"; } SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT); String name = sdf.format(cal.getTime()); dbhelper.open(); long id = dbhelper.createClockIn( name, myCurrentAdress, myCurrentNeighborHood, cal.getTimeInMillis(), lastLocation); dbhelper.close(); Editor edit = sp.edit(); edit.putBoolean(Constants.KEY_IS_CLOCKED_IN, true); edit.putLong(Constants.KEY_CLOCKED_ID, id); edit.commit(); checkClockedIn(); }
public void saveIsFirst(Boolean isDisplay) { if (mSharePreference != null && isDisplay != null) { Editor editor = mSharePreference.edit(); editor.putBoolean(IS_FISRT, isDisplay); editor.commit(); } }
public void apply(View v) { // read raw values from the input widgets master_switch = switch_master_switch.isChecked(); left_margin = Integer.parseInt(ET_left_margin.getText().toString()); right_margin = Integer.parseInt(ET_right_margin.getText().toString()); top_margin = Integer.parseInt(ET_top_margin.getText().toString()); bottom_margin = Integer.parseInt(ET_bottom_margin.getText().toString()); // save the values Editor editor = pref.edit(); editor.putBoolean(Keys.MASTER_SWITCH, master_switch); editor.putInt(Keys.LEFT_MARGIN, left_margin); editor.putInt(Keys.RIGHT_MARGIN, right_margin); editor.putInt(Keys.TOP_MARGIN, top_margin); editor.putInt(Keys.BOTTOM_MARGIN, bottom_margin); editor.apply(); int viewH = (screen_height - top_margin - bottom_margin); Log.d("VIEW H", Integer.toString(viewH)); int viewW = screen_width - left_margin - right_margin; Log.d("VIEW W", Integer.toString(viewW)); Toast.makeText(this, "Changes applied!", Toast.LENGTH_SHORT).show(); if (viewW < screen_width * 0.5 || viewH < screen_height * 0.5) Toast.makeText(this, "Warning, the view area may be too small!", Toast.LENGTH_LONG).show(); if (left_margin > screen_width || top_margin > screen_height || right_margin < 0 || bottom_margin < 0) Toast.makeText(this, "Your view area goes off the screen!", Toast.LENGTH_LONG).show(); finish(); }
public static void setCountryIconsEnabled(Context context, boolean enabled) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); Editor editor = prefs.edit(); editor.putBoolean(PREFERENCE_ENABLE_COUNTRY_ICONS, enabled); editor.commit(); ObjectRelation.addRelation(editor, context); }
@Override protected Payload doInBackground(Payload... args) { Payload data = doInBackgroundLoadDeck(args); if (data.returnType == DeckTask.DECK_LOADED) { double now = System.currentTimeMillis(); HashMap<String, Object> results = (HashMap<String, Object>) data.result; Deck deck = (Deck) results.get("deck"); // deck.beforeUpdateCards(); // deck.updateAllCards(); SharedDeckDownload download = (SharedDeckDownload) args[0].data[0]; SharedPreferences pref = PrefSettings.getSharedPrefs(getBaseContext()); String updatedCardsPref = "numUpdatedCards:" + mDestination + "/tmp/" + download.getTitle() + ".anki.updating"; long totalCards = deck.retrieveCardCount(); download.setNumTotalCards((int) totalCards); long updatedCards = pref.getLong(updatedCardsPref, 0); download.setNumUpdatedCards((int) updatedCards); long batchSize = Math.max(100, totalCards / 200); mRecentBatchTimings = new long[sRunningAvgLength]; mTotalBatches = ((double) totalCards) / batchSize; int currentBatch = (int) (updatedCards / batchSize); long runningAvgCount = 0; long batchStart; mElapsedTime = 0; while (updatedCards < totalCards && download.getStatus() == SharedDeckDownload.STATUS_UPDATING) { batchStart = System.currentTimeMillis(); updatedCards = deck.updateAllCardsFromPosition(updatedCards, batchSize); Editor editor = pref.edit(); editor.putLong(updatedCardsPref, updatedCards); editor.commit(); download.setNumUpdatedCards((int) updatedCards); publishProgress(); estimateTimeToCompletion( download, currentBatch, runningAvgCount, System.currentTimeMillis() - batchStart); currentBatch++; runningAvgCount++; } if (download.getStatus() == SharedDeckDownload.STATUS_UPDATING) { data.success = true; } else if (download.getStatus() == SharedDeckDownload.STATUS_PAUSED) { Editor editor = pref.edit(); String pausedPref = "paused:" + mDestination + "/tmp/" + download.getTitle() + ".anki.updating"; editor.putBoolean(pausedPref, true); editor.commit(); data.success = false; Log.i(AnkiDroidApp.TAG, "pausing deck " + download.getTitle()); } else if (download.getStatus() == SharedDeckDownload.STATUS_CANCELLED) { data.success = false; } // Log.i(AnkiDroidApp.TAG, "Time to update deck = " + download.getEstTimeToCompletion() + " // sec."); // deck.afterUpdateCards(); } else { data.success = false; } return data; }
/** 设置登陆界面 已登陆:我的课表+我的资料 未登陆:登陆+注册 登陆状态改变时更新menudrawer的菜单显示 */ public void setLoginedFragment(String username) { this.username = username; mloginFragment = new HomeFragment(); if (username == null || "".equals(username)) { mloginFragment.addpager("登陆", new LoginFragment()); mloginFragment.addpager("注册", new RegistFragment()); SharedPreferences sp = getPreferences(0); Editor edit = sp.edit(); edit.putBoolean("autologin", false); edit.commit(); autologin = false; settingAdapter.setTitle0("登陆"); settingAdapter.setTitle("登陆"); } else { mloginFragment.addpager("我的课表", new MyCourseFragment()); mloginFragment.addpager("我的资料", new MyInfoFragment()); settingAdapter.setTitle0(username); settingAdapter.setTitle(username); } FragmentTransaction ft = fm.beginTransaction(); ft.replace(R.id.container, mloginFragment); ft.addToBackStack(null); ft.commit(); // settingAdapter.notifyDataSetChanged();//无法及时改变状态,不知道为什么 - - // settingAdapter.notifyDataSetInvalidated(); }
public void onClick(DialogInterface dialog, int whichItem) { int set = updateSleepPolicy(); boolean message = settings.getBoolean(PREF_MESSAGE, DEFAULT_MESSAGE); try { copyFile( new File(profilePath + profileFiles[whichItem]), new File(sharedPrefsPath + sharedPrefsFile + ".xml")); } catch (Exception e) { Toast.makeText( context, getString(R.string.settings_profile_import_error), Toast.LENGTH_SHORT) .show(); return; } setDefaultValues(); // Restart the engine Receiver.engine(context).halt(); Receiver.engine(context).StartEngine(); settings.unregisterOnSharedPreferenceChangeListener(context); reload(); settings.registerOnSharedPreferenceChangeListener(context); updateSummaries(); if (set != updateSleepPolicy()) updateSleep(); if (message) { Editor edit = settings.edit(); edit.putBoolean(PREF_MESSAGE, true); edit.commit(); } }
public void savePreset() { final int sbOne = sb1.getProgress(); final int sbTwo = sb2.getProgress(); final int sbThree = sb3.getProgress(); final int sbFour = sb4.getProgress(); final int sbFive = sb5.getProgress(); final int skOne = sk1.getProgress(); final int skTwo = sk2.getProgress(); final String preset = presetsSpinner.getSelectedItem().toString().trim(); Editor editor = prefs.edit(); editor.putBoolean(EQUALIZER_SAVE, true); editor.putString(EQUALIZER_PRESET, preset); if ("Custom".equals(preset)) { editor.putInt(EQUALIZER_VERTICAL_SEEKBAR_CUSTOM_ONE, sbOne); editor.putInt(EQUALIZER_VERTICAL_SEEKBAR_CUSTOM_TWO, sbTwo); editor.putInt(EQUALIZER_VERTICAL_SEEKBAR_CUSTOM_THREE, sbThree); editor.putInt(EQUALIZER_VERTICAL_SEEKBAR_CUSTOM_FOUR, sbFour); editor.putInt(EQUALIZER_VERTICAL_SEEKBAR_CUSTOM_FIVE, sbFive); editor.putInt(EQUALIZER_SEEKBAR_CUSTOM_ONE, skOne); editor.putInt(EQUALIZER_SEEKBAR_CUSTOM_TWO, skTwo); } else { editor.putInt(EQUALIZER_VERTICAL_SEEKBAR_ONE, sbOne); editor.putInt(EQUALIZER_VERTICAL_SEEKBAR_TWO, sbTwo); editor.putInt(EQUALIZER_VERTICAL_SEEKBAR_THREE, sbThree); editor.putInt(EQUALIZER_VERTICAL_SEEKBAR_FOUR, sbFour); editor.putInt(EQUALIZER_VERTICAL_SEEKBAR_FIVE, sbFive); editor.putInt(EQUALIZER_SEEKBAR_ONE, skOne); editor.putInt(EQUALIZER_SEEKBAR_TWO, skTwo); } editor.apply(); }
@Override protected void onHandleIntent(Intent intent) { try { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); String c2dmid = prefs.getString(KEY_P2REGISTRATION_ID, null); if (c2dmid != null) { long epoch = System.currentTimeMillis() / 1000; Tools.Register_Push_onServer( Tools.getDeviceId(C2DMRegistrationService.this), c2dmid, Long.toString(epoch)); SharedPreferences myPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); Editor edit = myPrefs.edit(); edit.putBoolean(KEY_P2REGISTRATION_UPDATED_ONSERVER, true); edit.commit(); } } catch (Exception e) { e.printStackTrace(); } }
void saveSettings() { if (!PreferenceManager.getDefaultSharedPreferences(Receiver.mContext) .getBoolean( org.sipdroid.sipua.ui.Settings.PREF_OLDVALID, org.sipdroid.sipua.ui.Settings.DEFAULT_OLDVALID)) { int oldvibrate = am.getVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER); int oldvibrate2 = am.getVibrateSetting(AudioManager.VIBRATE_TYPE_NOTIFICATION); if (!PreferenceManager.getDefaultSharedPreferences(Receiver.mContext) .contains(org.sipdroid.sipua.ui.Settings.PREF_OLDVIBRATE2)) oldvibrate2 = AudioManager.VIBRATE_SETTING_ON; int oldpolicy = android.provider.Settings.System.getInt( cr, android.provider.Settings.System.WIFI_SLEEP_POLICY, Settings.System.WIFI_SLEEP_POLICY_DEFAULT); Editor edit = PreferenceManager.getDefaultSharedPreferences(Receiver.mContext).edit(); edit.putInt(org.sipdroid.sipua.ui.Settings.PREF_OLDVIBRATE, oldvibrate); edit.putInt(org.sipdroid.sipua.ui.Settings.PREF_OLDVIBRATE2, oldvibrate2); edit.putInt(org.sipdroid.sipua.ui.Settings.PREF_OLDPOLICY, oldpolicy); edit.putInt( org.sipdroid.sipua.ui.Settings.PREF_OLDRING, am.getStreamVolume(AudioManager.STREAM_RING)); edit.putBoolean(org.sipdroid.sipua.ui.Settings.PREF_OLDVALID, true); edit.commit(); } }
@Override public void onCreate() { ACRA.init(this); super.onCreate(); this.prefs = PreferenceManager.getDefaultSharedPreferences(this); this.prefs.registerOnSharedPreferenceChangeListener((OnSharedPreferenceChangeListener) this); // See if the user has the preference for opening up the last used database. If so, set the path // to it. if (this.prefs.getBoolean("openLastUsed", false)) { // First see if the path still exists if not then the user did something and we need to change // the user preference and not // try to open any file this time around. String path = this.prefs.getString("Full Path", ""); if (fileExists(path)) setFullPath(path); else { Editor edit = this.prefs.edit(); edit.putBoolean("openLastUsed", false); edit.putString("Full Path", ""); edit.apply(); } } String value = this.prefs.getString("updateFrequency", "0"); if (value.equals("-1")) this.setAutoUpdate(true); else this.setAutoUpdate(false); Splits = new ArrayList<Split>(); Splits.clear(); }
public static void setAcceptedEULA(Context context, boolean accepted) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); Editor editor = prefs.edit(); editor.putBoolean(PREFERENCE_IS_EULA_ACCEPTED, accepted); editor.commit(); ObjectRelation.addRelation(editor, context); }
private void setLoggedin(boolean loggedIn) { SharedPreferences prefs = parentActivity.getSharedPreferences(ACCOUNT_PREFS_NAME, Context.MODE_PRIVATE); Editor edit = prefs.edit(); edit.putBoolean(LOGIN_FLAG, loggedIn); edit.commit(); }
void setFbSync() { if (editor == null) { Editor edt = prefs.edit(); edt.putBoolean(HAD_FB_SYNC, true); edt.commit(); } else editor.putBoolean(HAD_FB_SYNC, true); }