当前位置: 首页>>代码示例>>Java>>正文


Java SharedPreferences.getBoolean方法代码示例

本文整理汇总了Java中android.content.SharedPreferences.getBoolean方法的典型用法代码示例。如果您正苦于以下问题:Java SharedPreferences.getBoolean方法的具体用法?Java SharedPreferences.getBoolean怎么用?Java SharedPreferences.getBoolean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.SharedPreferences的用法示例。


在下文中一共展示了SharedPreferences.getBoolean方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createSubsonicApiClient

import android.content.SharedPreferences; //导入方法依赖的package包/类
private static SubsonicAPIClient createSubsonicApiClient(final Context context) {
    final SharedPreferences preferences = Util.getPreferences(context);
    int instance = preferences.getInt(Constants.PREFERENCES_KEY_SERVER_INSTANCE, 1);
    String serverUrl = preferences.getString(Constants.PREFERENCES_KEY_SERVER_URL + instance, null);
    String username = preferences.getString(Constants.PREFERENCES_KEY_USERNAME + instance, null);
    String password = preferences.getString(Constants.PREFERENCES_KEY_PASSWORD + instance, null);
    boolean allowSelfSignedCertificate = preferences
            .getBoolean(Constants.PREFERENCES_KEY_ALLOW_SELF_SIGNED_CERTIFICATE + instance, false);

    if (serverUrl == null ||
            username == null ||
            password == null) {
        Log.i("MusicServiceFactory", "Server credentials is not available");
        return new SubsonicAPIClient("http://localhost", "", "",
                SubsonicAPIVersions.fromApiVersion(Constants.REST_PROTOCOL_VERSION),
                Constants.REST_CLIENT_ID, allowSelfSignedCertificate, BuildConfig.DEBUG);
    }

    return new SubsonicAPIClient(serverUrl, username, password,
            SubsonicAPIVersions.fromApiVersion(Constants.REST_PROTOCOL_VERSION),
            Constants.REST_CLIENT_ID, allowSelfSignedCertificate, BuildConfig.DEBUG);
}
 
开发者ID:ultrasonic,项目名称:ultrasonic,代码行数:23,代码来源:MusicServiceFactory.java

示例2: setDarkTheme

import android.content.SharedPreferences; //导入方法依赖的package包/类
public static void setDarkTheme(Context context) {
    SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
    boolean darkTheme = sharedPrefs.getBoolean(context.getString(R.string.key_themes_pref), false);
    if (darkTheme) {
        context.setTheme(R.style.AppThemeDark);
    } else {
        context.setTheme(R.style.AppThemeLight);
    }
}
 
开发者ID:personaljesusua,项目名称:DepressingThoughts,代码行数:10,代码来源:AppSettings.java

示例3: get

import android.content.SharedPreferences; //导入方法依赖的package包/类
/**
 * 获取存放object
 * @param context
 * @param fileName
 * @param key
 * @param def
 * @return
 */
public static Object get(Context context, String fileName, String key, Object def) {
    SharedPreferences sp = context.getSharedPreferences(fileName, Context.MODE_PRIVATE);
    if (def instanceof String) {
        return sp.getString(key, def.toString());
    } else if (def instanceof Integer) {
        return sp.getInt(key, ((Integer) def).intValue());
    } else if (def instanceof Boolean) {
        return sp.getBoolean(key, ((Boolean) def).booleanValue());
    } else if (def instanceof Float) {
        return sp.getFloat(key, ((Float) def).floatValue());
    } else if (def instanceof Long) {
        return sp.getLong(key, ((Long) def).longValue());
    } else if (def instanceof Set) {
        return sp.getStringSet(key, (Set<String>) def);
    }
    return def;
}
 
开发者ID:AriesHoo,项目名称:FastLib,代码行数:26,代码来源:SPUtil.java

示例4: onResume

import android.content.SharedPreferences; //导入方法依赖的package包/类
@Override
protected void onResume() {
    super.onResume();
    SharedPreferences prefs = getPreferences(MODE_PRIVATE);
    doBuildInfo = prefs.getBoolean("doBuildInfo", doBuildInfo);
    doMemoryInfo = prefs.getBoolean("doMemoryInfo", doMemoryInfo);
    doPreferredApplications = prefs.getBoolean("doPreferredApplications",
            doPreferredApplications);
    doNonSystemApps = prefs.getBoolean("doNonSystemApps", doNonSystemApps);
    doSystemApps = prefs.getBoolean("doSystemApps", doSystemApps);

    refresh();
}
 
开发者ID:KennethEvans,项目名称:Misc,代码行数:14,代码来源:AppsActivity.java

示例5: handlePermissions

import android.content.SharedPreferences; //导入方法依赖的package包/类
private void handlePermissions() {

        SharedPreferences permissionStatus = this.getSharedPreferences("permissionStatus",
                this.MODE_PRIVATE);

        if (ActivityCompat.checkSelfPermission(this, permissionsRequired[0]) != PackageManager
                .PERMISSION_GRANTED
                || ActivityCompat.checkSelfPermission(this, permissionsRequired[1]) !=
                PackageManager.PERMISSION_GRANTED) {
            if (ActivityCompat.shouldShowRequestPermissionRationale(this, permissionsRequired[0])
                    || ActivityCompat.shouldShowRequestPermissionRationale(this,
                    permissionsRequired[1])) {
                //true means user not allowed the permission but may we can convince him/her
                //false have two meaning: 1-user not asked for permission 2-user denied and check
                // 'Don't Ask Again'
                //so we had to Show Information about why you need the permission

                ActivityCompat.requestPermissions(this, permissionsRequired,
                        PERMISSION_CALLBACK_CONSTANT);

            } else if (permissionStatus.getBoolean(permissionsRequired[0], false)) {
                //Previously Permission Request was cancelled with 'Dont Ask Again',
                // Redirect to Settings after showing Information about why you need the permission

                Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
                Uri uri = Uri.fromParts("package", this.getPackageName(), null);
                intent.setData(uri);
                this.startActivityForResult(intent, REQUEST_PERMISSION_SETTING);
                Toast.makeText(this, "Go to Permissions to Grant Sms", Toast.LENGTH_LONG)
                        .show();

            } else {
                //just request the permission
                ActivityCompat.requestPermissions(this, permissionsRequired,
                        PERMISSION_CALLBACK_CONSTANT);
            }

            SharedPreferences.Editor editor = permissionStatus.edit();
            editor.putBoolean(permissionsRequired[0], true).apply();

        } else {

            proceedAfterPermission();

        }
    }
 
开发者ID:mahdit83,项目名称:advancedSmsManager,代码行数:47,代码来源:MainActivity.java

示例6: start

import android.content.SharedPreferences; //导入方法依赖的package包/类
public void start(Context c) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(c);
    if (prefs.getBoolean("notifications_new_message", true) && WalletStorage.getInstance(c).get().size() >= 1) {
        service = (AlarmManager) c.getSystemService(Context.ALARM_SERVICE);
        Intent i = new Intent(c, NotificationService.class);
        pintent = PendingIntent.getService(c, 23, i, 0);

        int syncInt = Integer.parseInt(prefs.getString("sync_frequency", "4"));

        service.setInexactRepeating(AlarmManager.RTC_WAKEUP,
                System.currentTimeMillis(), AlarmManager.INTERVAL_HOUR * syncInt, pintent);
    }
}
 
开发者ID:manuelsc,项目名称:Lunary-Ethereum-Wallet,代码行数:14,代码来源:NotificationLauncher.java

示例7: getBoolean

import android.content.SharedPreferences; //导入方法依赖的package包/类
public static Boolean getBoolean(Context context, String strKey,
                                 Boolean strDefault) {
    SharedPreferences setPreferences = context.getSharedPreferences(
            spFileName, Context.MODE_PRIVATE);
    Boolean result = setPreferences.getBoolean(strKey, strDefault);
    return result;
}
 
开发者ID:haihaio,项目名称:AmenEye,代码行数:8,代码来源:SpUtil.java

示例8: onIncomingCallStarted

import android.content.SharedPreferences; //导入方法依赖的package包/类
protected void onIncomingCallStarted(Context context, String number)
{
	try
	{
		SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
		boolean isPreferencesFiltersActivated = sharedPreferences.getBoolean("preferences_filters_activate",false);
		
		if((isPreferencesFiltersActivated == false) || ((isPreferencesFiltersActivated == true) && (isRecordableContact == 1)))
		{
			RecordServiceManager recordServiceManager = new RecordServiceManager();
			recordServiceManager.startService(context.getApplicationContext(), 0, number);
		}
		else
		{
			if((isPreferencesFiltersActivated == true) && (isRecordableContact != 0))
			{
				ShakeDetectorServiceManager shakeDetectorServiceManager = new ShakeDetectorServiceManager();
				shakeDetectorServiceManager.startService(context.getApplicationContext(), 0, number);
			}
		}
	}
	catch (Exception e)
	{
		Log.e("TelephoneCallReceiver", "onIncomingCallStarted : " + context.getApplicationContext().getString(R.string.log_telephone_call_receiver_error_incoming_call_started) + " : " + number + " : " + e);
		databaseManager.insertLog(context.getApplicationContext(), "" + context.getApplicationContext().getString(R.string.log_telephone_call_receiver_error_incoming_call_started) + " : " + number, new Date().getTime(), 1, false);
	}
}
 
开发者ID:vassela,项目名称:AC2RD,代码行数:28,代码来源:TelephoneCallReceiver.java

示例9: onResume

import android.content.SharedPreferences; //导入方法依赖的package包/类
@Override
public void onResume() {
    super.onResume();
    SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
    boolean animations = preferences.getBoolean("view_animations", true);
    if (!animations) {
        aboutField.requestFocus();
        AndroidUtilities.showKeyboard(aboutField);
    }
    updateTheme();
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:12,代码来源:ChangeAboutActivity.java

示例10: DecodeThread

import android.content.SharedPreferences; //导入方法依赖的package包/类
DecodeThread(CaptureActivity activity, Vector<BarcodeFormat> decodeFormats, String characterSet,
			 ResultPointCallback resultPointCallback)
{

	this.activity = activity;
	handlerInitLatch = new CountDownLatch(1);

	hints = new Hashtable<DecodeHintType, Object>(3);

	// The prefs can't change while the thread is running, so pick them up once here.
	if (decodeFormats == null || decodeFormats.isEmpty())
	{
		SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
		decodeFormats = new Vector<BarcodeFormat>();
		if (prefs.getBoolean(PreferencesActivity.KEY_DECODE_1D, true))
		{
			decodeFormats.addAll(DecodeFormatManager.ONE_D_FORMATS);
		}
		if (prefs.getBoolean(PreferencesActivity.KEY_DECODE_QR, true))
		{
			decodeFormats.addAll(DecodeFormatManager.QR_CODE_FORMATS);
		}
		if (prefs.getBoolean(PreferencesActivity.KEY_DECODE_DATA_MATRIX, true))
		{
			decodeFormats.addAll(DecodeFormatManager.DATA_MATRIX_FORMATS);
		}
	}
	hints.put(DecodeHintType.POSSIBLE_FORMATS, decodeFormats);

	if (characterSet != null)
	{
		hints.put(DecodeHintType.CHARACTER_SET, characterSet);
	}

	hints.put(DecodeHintType.NEED_RESULT_POINT_CALLBACK, resultPointCallback);
}
 
开发者ID:guzhigang001,项目名称:Zxing,代码行数:37,代码来源:DecodeThread.java

示例11: getBoolean

import android.content.SharedPreferences; //导入方法依赖的package包/类
public static boolean getBoolean(Context context, String key) {
    SharedPreferences sp = getSP(context);
    return sp.getBoolean(key, false);
}
 
开发者ID:StableChen,项目名称:easynote,代码行数:5,代码来源:SPUtil.java

示例12: readShowsLanguageSwitchKey

import android.content.SharedPreferences; //导入方法依赖的package包/类
public static boolean readShowsLanguageSwitchKey(final SharedPreferences prefs) {
    return !prefs.getBoolean(PREF_HIDE_LANGUAGE_SWITCH_KEY, false);
}
 
开发者ID:rkkr,项目名称:simple-keyboard,代码行数:4,代码来源:Settings.java

示例13: getShouldSendBluetoothAlbumArt

import android.content.SharedPreferences; //导入方法依赖的package包/类
public static boolean getShouldSendBluetoothAlbumArt(Context context)
{
	SharedPreferences preferences = getPreferences(context);
	return preferences.getBoolean(Constants.PREFERENCES_KEY_SEND_BLUETOOTH_ALBUM_ART, true);
}
 
开发者ID:ultrasonic,项目名称:ultrasonic,代码行数:6,代码来源:Util.java

示例14: setPlayProfileAnimation

import android.content.SharedPreferences; //导入方法依赖的package包/类
public void setPlayProfileAnimation(boolean value) {
    SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
    if (!AndroidUtilities.isTablet() && preferences.getBoolean("view_animations", true)) {
        playProfileAnimation = value;
    }
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:7,代码来源:ProfileActivity.java

示例15: getBoolean

import android.content.SharedPreferences; //导入方法依赖的package包/类
public static boolean getBoolean(Context context, int key, boolean defValue) {
    SharedPreferences
            pref = PreferenceManager
            .getDefaultSharedPreferences(context);
    return pref.getBoolean(context.getString(key), defValue);
}
 
开发者ID:ayounes3333,项目名称:GSB-2017-Android,代码行数:7,代码来源:PrefUtils.java


注:本文中的android.content.SharedPreferences.getBoolean方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。