List of usage examples for android.content SharedPreferences contains
boolean contains(String key);
From source file:com.crte.sipstackhome.ui.preferences.PreferencesWrapper.java
/** * boolean?/* w ww . jav a2 s . c om*/ * * @param aPrefs * @param key * @return */ private static Boolean gPrefBooleanValue(SharedPreferences aPrefs, String key) { if (aPrefs == null) { return BOOLEAN_PREFS.get(key); } if (BOOLEAN_PREFS.containsKey(key)) { return aPrefs.getBoolean(key, BOOLEAN_PREFS.get(key)); } if (aPrefs.contains(key)) { return aPrefs.getBoolean(key, false); } return null; }
From source file:com.jins_meme.bridge.MenuFragmentBase.java
protected void restoreUIPosition() { String id_str = ((Integer) mView.getCurrentParentCardId()).toString(); SharedPreferences pref = getPreferences(); if (pref.contains(id_str)) { int offset = getPreferences().getInt(id_str, 0); mView.setPosition(offset);/* w w w . j a va 2 s. com*/ } else { mView.setToDefaultPosition(0); } }
From source file:cn.newgxu.android.notty.ui.ServiceItems.java
@Override public void onClick(View v) { switch (v.getId()) { case R.id.go_to_auth: Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(getString(R.string.auth_uri))); startActivity(intent);/*from w ww. j a v a2 s . c o m*/ break; case R.id.login: NottyApplication app = NottyApplication.getApp(); SharedPreferences prefs = app.getPrefs(); if (prefs.contains(C.ACCOUNT) && prefs.contains(C.PWD)) { startActivity(new Intent(getActivity(), UserServiceActivity.class)); // final String account = prefs.getString(C.ACCOUNT, null); // final String pwd = prefs.getString(C.PWD, null); // new Handler().post(new Runnable() { // // @Override // public void run() { // JSONObject result = RESTMethod.get(C.DOMAIN // + "/info/login?account=" + account + "&pwd=" + pwd); // try { // if (result.getInt(C.STATUS) == C.OK) { // Intent intent = new Intent(getActivity(), UserServiceActivity.class); // startActivity(intent); // } else { // Toast.makeText(getActivity(), getString(R.string.login_no) // + result.getString(C.MSG), Toast.LENGTH_SHORT).show(); // } // } catch (Exception e) { // Toast.makeText(getActivity(), getString(R.string.login_error), Toast.LENGTH_SHORT).show(); // } // } // }); } else { LoginBoxFragment fragment = new LoginBoxFragment(); fragment.show(getFragmentManager(), "login"); } break; default: break; } }
From source file:com.weiboa.data.WeiboOAuthConnect.java
private void loadSavedKeys(SharedPreferences sp) { // We look for saved user keys if (sp.contains(WeiboUser.KEY_ACCESS_TOKEN) && sp.contains(WeiboUser.KEY_ACCESS_TOKEN_SECRET)) { mToken = sp.getString(WeiboUser.KEY_ACCESS_TOKEN, null); mSecret = sp.getString(WeiboUser.KEY_ACCESS_TOKEN_SECRET, null); if (!(mToken == null || mSecret == null)) { mConsumer.setTokenWithSecret(mToken, mSecret); }//from www.j a va2 s .co m } }
From source file:org.bubenheimer.android.preference.EditIntPreference.java
@Override protected final String getPersistedString(final String defaultReturnValue) { if (!shouldPersist()) { return defaultReturnValue; }//from ww w. j a va 2 s . c om final SharedPreferences sharedPreferences = getPreferenceManager().getSharedPreferences(); final String key = getKey(); if (!sharedPreferences.contains(key)) { return defaultReturnValue; } //the 0 default will never be used - we've covered the case of value absence above final int value = sharedPreferences.getInt(key, 0); return Integer.toString(value); }
From source file:com.noswap.keyring.MainActivity.java
private Intent versionUpgrade() { Intent intent = null;/*from www . j a v a2 s.c om*/ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); if (prefs.contains("last_version")) { // TODO: check if we need to upgrade settings or something } else { // TODO: inject register/login flow here } return intent; }
From source file:fr.cph.stock.android.activity.BaseActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { Log.v(TAG, "BaseActivity onCreate"); super.onCreate(savedInstanceState); setContentView(R.layout.loading);/* w w w . j av a2 s . c o m*/ mLoginStatusView = findViewById(R.id.login_status); SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); if (settings.contains("login") && settings.contains("password")) { showProgress(true, null); login = settings.getString("login", null); password = settings.getString("password", null); UrlType urlAuth = UrlType.AUTH; String params = "?login=" + login + "&password=" + password; MainTask derp = new MainTask(this, urlAuth, params); derp.execute((Void) null); } else { showProgress(false, null); Intent intent = new Intent(this, LoginActivity.class); startActivity(intent); finish(); } EasyTracker.getInstance().setContext(this); }
From source file:edu.tsinghua.hotmobi.UploadLogsTask.java
@Override public void run() { final SharedPreferences prefs = context.getSharedPreferences("spice_data_profiling", Context.MODE_PRIVATE); if (prefs.contains(HotMobiLogger.LAST_UPLOAD_TIME)) { final long lastUpload = prefs.getLong(HotMobiLogger.LAST_UPLOAD_TIME, System.currentTimeMillis()); final double deltaDays = (System.currentTimeMillis() - lastUpload) / (double) HotMobiLogger.UPLOAD_INTERVAL_MILLIS; if (deltaDays < 1) { SpiceProfilingUtil.log("Last uploaded was conducted in 1 day ago."); return; }/*from w w w .j a v a 2 s. com*/ } if (uploadLogs()) { prefs.edit().putLong(HotMobiLogger.LAST_UPLOAD_TIME, System.currentTimeMillis()).apply(); } }
From source file:pt.up.fe.cmov.propertymarket.C2DMReceiver.java
@Override public void onRegistered(Context context, String registrationId) { Log.w("C2DMReceiver-onRegistered", registrationId); SharedPreferences prefs = context.getSharedPreferences(PropertyMarketActivity.PREFS_NAME, MODE_PRIVATE); if (!prefs.contains(PropertyMarketActivity.USER_EMAIL)) { Log.w("PM-Registration", "Client doesn't have an email account. Using default!"); }/* w ww . ja v a 2s . co m*/ String userEmail = prefs.getString(PropertyMarketActivity.USER_EMAIL, "joao.portela@gmail.com"); Editor prefsEditor = prefs.edit(); prefsEditor.putString(PropertyMarketActivity.REGISTRATION_ID, registrationId); prefsEditor.commit(); JSONObject obj; try { obj = new JSONObject("{ 'email': '" + userEmail + "', 'registration_id': '" + registrationId + "'}"); RailsRestClient.Post("users/update_registration", obj); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ConnectTimeoutException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.example.administrator.myapplication2._4_Detail.LeftFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout._2_fragment_main_dummy, container, false); Intent myIntent = getActivity().getIntent(); if (myIntent != null) { seq = myIntent.getStringExtra("seq"); }//from w ww . j a va 2s .c om tvHeart = (TextView) rootView.findViewById(R.id.tvHeart); tvDistance = (TextView) rootView.findViewById(R.id.tvDistance); tvCalorie = (TextView) rootView.findViewById(R.id.tvCalorie); tvWeight = (TextView) rootView.findViewById(R.id.tvWeight); ; tvRuntime = (TextView) rootView.findViewById(R.id.tvRuntime); SharedPreferences myPrefs = this.getActivity().getSharedPreferences("login", Context.MODE_PRIVATE); if ((myPrefs != null) && (myPrefs.contains("id"))) { id = myPrefs.getString("id", ""); Log.i("logintest", id.toString()); } getRecentData(); return rootView; }