List of usage examples for android.content SharedPreferences getBoolean
boolean getBoolean(String key, boolean defValue);
From source file:com.dmbstream.android.util.Util.java
public static boolean getIsDonor(Context context) { SharedPreferences prefs = getPreferences(context); return prefs.getBoolean(Constants.SHARED_IS_DONOR, false); }
From source file:com.dmbstream.android.util.Util.java
public static boolean isScreenLitOnDownload(Context context) { SharedPreferences prefs = getPreferences(context); return prefs.getBoolean(Constants.PREFERENCES_KEY_SCREEN_LIT_ON_DOWNLOAD, false); }
From source file:com.dmbstream.android.util.Util.java
public static boolean getShouldScrobble(Context context) { SharedPreferences prefs = getPreferences(context); return prefs.getBoolean(Constants.PREFERENCES_KEY_SCROBBLE, true); }
From source file:com.dmbstream.android.util.Util.java
private static boolean isWifiRequiredForDownload(Context context) { SharedPreferences prefs = getPreferences(context); return prefs.getBoolean(Constants.PREFERENCES_KEY_WIFI_REQUIRED_FOR_DOWNLOAD, false); }
From source file:com.facebook.FacebookSdk.java
/** * Returns whether data such as those generated through AppEventsLogger and sent to Facebook * should be restricted from being used for purposes other than analytics and conversions, such * as targeting ads to this user. Defaults to false. This value is stored on the device and * persists across app launches./*from www . j av a 2s. c o m*/ * * @param context Used to read the value. */ public static boolean getLimitEventAndDataUsage(Context context) { Validate.sdkInitialized(); SharedPreferences preferences = context.getSharedPreferences(AppEventsLogger.APP_EVENT_PREFERENCES, Context.MODE_PRIVATE); return preferences.getBoolean("limitEventUsage", false); }
From source file:com.fusionx.lightirc.util.SharedPreferencesUtils.java
public static ServerConfiguration.Builder getDefaultNewServer(final Context context) { final ServerConfiguration.Builder builder = new ServerConfiguration.Builder(); final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); final String firstNick = preferences.getString(PreferenceConstants.PREF_DEFAULT_FIRST_NICK, "holoirc"); final String secondNick = preferences.getString(PreferenceConstants.PREF_DEFAULT_SECOND_NICK, ""); final String thirdNick = preferences.getString(PreferenceConstants.PREF_DEFAULT_THIRD_NICK, ""); builder.setNickStorage(new NickStorage(firstNick, secondNick, thirdNick)); final String realName = preferences.getString(PreferenceConstants.PREF_DEFAULT_REALNAME, "HoloIRCUser"); builder.setRealName(realName);//from www . j ava 2s . co m final boolean autoNick = preferences.getBoolean(PreferenceConstants.PREF_DEFAULT_AUTO_NICK, true); builder.setNickChangeable(autoNick); builder.setServerUserName("holoirc"); return builder; }
From source file:com.dmbstream.android.util.Util.java
public static void registerMediaButtonEventReceiver(Context context) { // Only do it if enabled in the settings. SharedPreferences prefs = getPreferences(context); boolean enabled = prefs.getBoolean(Constants.PREFERENCES_KEY_MEDIA_BUTTONS, true); if (enabled) { // AudioManager.registerMediaButtonEventReceiver() was introduced in Android 2.2. // Use reflection to maintain compatibility with 1.5. try {//from w w w.j a v a 2 s . c o m AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); ComponentName componentName = new ComponentName(context.getPackageName(), MediaButtonIntentReceiver.class.getName()); Method method = AudioManager.class.getMethod("registerMediaButtonEventReceiver", ComponentName.class); method.invoke(audioManager, componentName); } catch (Throwable x) { // Ignored. } } }
From source file:edu.polyu.screamalert.SoundProcessing.java
private static void sendSMS() { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Exchanger.thisContext); Boolean enableSMS = prefs.getBoolean("enableSMS", false); String phoneNumber = prefs.getString("phoneNumber", null); TelephonyManager phoneMgr = (TelephonyManager) thisContext.getSystemService(Context.TELEPHONY_SERVICE); if (enableSMS == true && phoneNumber != null && phoneNumber.trim().length() > 0 && phoneMgr.getSimState() != TelephonyManager.SIM_STATE_ABSENT) { SmsManager smsManager = SmsManager.getDefault(); smsManager.sendTextMessage(phoneNumber, null, "Scream detected. Longitude: " + gps.getLongitude() + "; Latitude: " + gps.getLatitude() + ". Please try to contact the mobile user", null, null); }/*from w w w . j a v a2 s. com*/ }
From source file:edu.polyu.screamalert.SoundProcessing.java
private static void sendEmail() { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Exchanger.thisContext); Boolean enableEmail = prefs.getBoolean("enableEmail", false); String toEmailAdd = prefs.getString("emailToAddress", null); // Recipient of the email String fromEmailAdd = prefs.getString("emailFromAddress", null); // Sender of email String fromPassword = prefs.getString("emailFromPassword", null); // Password of the email sender account System.out.println("Email: Preparing email"); String emailBody = "Scream detected. Longitude: " + gps.getLongitude() + "; Latitude: " + gps.getLatitude() + ". Please try to contact the mobile user"; if (enableEmail) { if (fromEmailAdd.trim().length() > 0 && fromPassword.trim().length() > 0) { try { GMailSender sender = new GMailSender(fromEmailAdd, fromPassword); sender.sendMail("Scream Detected", emailBody, fromEmailAdd, toEmailAdd); } catch (Exception e) { Log.e("SendMail", e.getMessage(), e); }//from w ww. j a v a 2 s .c o m } } }
From source file:com.scoreflex.ScoreflexRestClient.java
/** * Is the access token stored in the user's shared preferences anonymous ? * * @return/* w w w . j ava2s. c o m*/ */ protected static boolean getAccessTokenIsAnonymous() { SharedPreferences prefs = Scoreflex.getSharedPreferences(); if (null == prefs) { return true; } return prefs.getBoolean(ACCESS_TOKEN_IS_ANONYMOUS_PREF_NAME, true); }