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


C# ISharedPreferences.GetBoolean方法代码示例

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


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

示例1: OnSharedPreferenceChanged

		public void OnSharedPreferenceChanged (ISharedPreferences sharedPreferences, string key)
		{
			Console.WriteLine ("Preference Changed: " + key);

			switch (key) {
			case "prefshowxamarin":
				settings.ShowXamarinLogo = sharedPreferences.GetBoolean (key, true);
				break;
			case "pref24hourclock":
				settings.Use24Clock = sharedPreferences.GetBoolean (key, false);
				break;
			case "prefshowdayofweek":
				settings.ShowDayOfWeek = sharedPreferences.GetBoolean (key, true);
				break;
			case "prefshowdate":
				settings.ShowDate = sharedPreferences.GetBoolean (key, true);
				break;
			}

			settings.Save ();
			Console.WriteLine ("Settings> " + settings);

			var evt = OnSettingsChanged;
			if (evt != null)
				evt (settings);
		}
开发者ID:Redth,项目名称:Xamarin.Wear.WatchFace,代码行数:26,代码来源:SettingsFragment.cs

示例2: Create

 public static AppPreferences Create(ISharedPreferences prefs)
 {
     return new AndroidAppPreferences(prefs)
     {
         FirtsTimeRunning = prefs.GetBoolean(AppPreferences.FirstTimeKey, true),
         Ip = prefs.GetString(AppPreferences.IpKey, ""),
         Port = prefs.GetInt(AppPreferences.PortKey, 0),
         UseSounds = prefs.GetBoolean(AppPreferences.UseSoundsKey, true),
         UseCache = prefs.GetBoolean(AppPreferences.UseCacheKey, true)
     };
 }
开发者ID:samiy-xx,项目名称:KeySndr.Clients,代码行数:11,代码来源:AndroidAppPreferences.cs

示例3: OnSharedPreferenceChanged

        public void OnSharedPreferenceChanged(ISharedPreferences sharedPreferences, string key)
        {
            string value = string.Empty;

            if (key != "clearCache" && key != "anonymousAccess")
            {
                Preference preference = (Preference)FindPreference(key);

                value = sharedPreferences.GetString(key, string.Empty);

                FillSummary(key, value);

                if ((key == "user" || key == "password" || key == "url") && !sharedPreferences.GetBoolean("clearCache", true))
                {
                    ISharedPreferencesEditor editor = sharedPreferences.Edit();
                    editor.PutBoolean("clearCache", true);
                    editor.Commit();

                    Toast.MakeText(this, D.NEED_TO_REBOOT_FULL, ToastLength.Long).Show();
                }

                if (key == "application")
                {
                    Toast.MakeText(this, D.NEED_TO_REBOOT, ToastLength.Long).Show();
                }
            }
            else
            {
                if (key == "anonymousAccess")
                {
                    string user = "";
                    string password = "";
                    if (sharedPreferences.GetBoolean("anonymousAccess", false))
                    {
                        user = Settings.AnonymousUserName;
                        password = Settings.AnonymousPassword;
                    }
                    ISharedPreferencesEditor editor = sharedPreferences.Edit();
                    editor.PutString("user", user);
                    editor.PutString("password", password);
                    editor.Commit();
                }

                Toast.MakeText(this, D.NEED_TO_REBOOT_FULL, ToastLength.Long).Show();
            }

            BitBrowserApp.Current.SyncSettings(true);
        }
开发者ID:Fedorm,项目名称:core-master,代码行数:48,代码来源:PreferencesScreen.cs

示例4: OnCreate

        public override void OnCreate()
        {
            base.OnCreate();

            Instance = this;

            // Load preferences
            Preferences = GetSharedPreferences(SettingsFilename, FileCreationMode.Private);
            // Default offline mode
            D3Context.Instance.FetchMode = (Preferences.GetBoolean(SettingsOnlinemode, false) ? FetchMode.Online : FetchMode.OnlineIfMissing);

            // Checks if some migration operations are needed
            var upToDateVersion = Preferences.GetInt(UpToDateVersion, 1);
            if (upToDateVersion < 20)
            {
                new MigrationTo20().DoMigration();
            }

            // Always start D3Api with cache available
            var dataProvider = new CacheableDataProvider(new HttpRequestDataProvider())
            {
                FetchMode = D3Context.Instance.FetchMode
            };
            D3Api.DataProvider = dataProvider;

            // Set english locale by default
            D3Api.Locale = CultureInfo.CurrentCulture.TwoLetterISOLanguageName;
        }
开发者ID:djtms,项目名称:D3-Android-by-ZTn,代码行数:28,代码来源:D3Calc.cs

示例5: OnCreate

		protected override void OnCreate (Bundle savedInstanceState)
		{
			base.OnCreate (savedInstanceState);
			SetContentView(Resource.Layout.main_activity);

			mAddGeofencesButton = FindViewById<Button>(Resource.Id.add_geofences_button);
			mRemoveGeofencesButton = FindViewById<Button>(Resource.Id.remove_geofences_button);

			mAddGeofencesButton.Click += AddGeofencesButtonHandler;
			mRemoveGeofencesButton.Click += RemoveGeofencesButtonHandler;

			mGeofenceList = new List<IGeofence>();

			mGeofencePendingIntent = null;

			mSharedPreferences = GetSharedPreferences(Constants.SHARED_PREFERENCES_NAME,
				FileCreationMode.Private);

			mGeofencesAdded = mSharedPreferences.GetBoolean(Constants.GEOFENCES_ADDED_KEY, false);
			SetButtonsEnabledState();

			PopulateGeofenceList();

			BuildGoogleApiClient();
		}
开发者ID:jingyul,项目名称:monodroid-samples,代码行数:25,代码来源:MainActivity.cs

示例6: Settings

        public Settings(ISharedPreferences preferences, string systemLanguage, InfobaseManager.Infobase infobase)
        {
            _preferences = preferences;
            Language = systemLanguage;

            _name = infobase.Name;

            BaseUrl = infobase.BaseUrl;
            ApplicationString = infobase.ApplicationString;

            FtpPort = infobase.FtpPort;

            string lastUrl = _preferences.GetString("url", string.Empty);
            if (BaseUrl == lastUrl)
            {
                UserName = _preferences.GetString("user", infobase.UserName);
                Password = _preferences.GetString("password", infobase.Password);
            }
            else
            {
                UserName = infobase.UserName;
                Password = infobase.Password;
            }

            ClearCacheOnStart = infobase.IsActive && _preferences.GetBoolean("clearCache", ForceClearCache);

            infobase.IsActive = true;
            infobase.IsAutorun = true;

            WriteSettings();
        }
开发者ID:Fedorm,项目名称:core-master,代码行数:31,代码来源:Settings.cs

示例7: OnSharedPreferenceChanged

        public void OnSharedPreferenceChanged(ISharedPreferences sharedPreferences, string key)
        {
            if (key != "clearCache" && key != "anonymousAccess")
            {
                string value = sharedPreferences.GetString(key, string.Empty);

                FillSummary(key, value);

                if ((key == "user" || key == "password" || key == "url") && !sharedPreferences.GetBoolean("clearCache", true))
                {
                    ISharedPreferencesEditor editor = sharedPreferences.Edit();
                    editor.PutBoolean("clearCache", true);
                    editor.Commit();

                    MakeToast(D.NEED_TO_REBOOT_FULL);
                }

                if (key == "application")
                    MakeToast(D.NEED_TO_REBOOT);
            }
            else
            {
                MakeToast(D.NEED_TO_REBOOT_FULL);
            }

            BitBrowserApp.Current.SyncSettings();
        }
开发者ID:Fedorm,项目名称:core-master,代码行数:27,代码来源:PreferencesScreen.cs

示例8: OtherSettings

 internal OtherSettings(ISharedPreferences sharedPrefs)
 {
     ConnectTimeout = int.Parse(sharedPrefs.GetString("pref_timeout_connect", "10000"));
     ConnectCheckInterval = int.Parse(sharedPrefs.GetString("pref_interval_check_connect", "200"));
     ToastLevel = (ToastLevel)int.Parse(sharedPrefs.GetString("pref_toasts_level", "2"));
     IgnoreSslCertErrors = sharedPrefs.GetBoolean("pref_ignore_ssl_errors", true);
     StartUrl = sharedPrefs.GetString("pref_start_url", null);
 }
开发者ID:t-denis,项目名称:CiscoWLC.WebAuth.Client,代码行数:8,代码来源:OtherSettings.cs

示例9: OnHandleIntent

        protected override void OnHandleIntent(Intent intent)
        {
            lastIntent = intent;
            Bundle extras = intent.Extras;
            GoogleCloudMessaging gcm = GoogleCloudMessaging.GetInstance(this);
            string messageType = gcm.GetMessageType(intent);


            if(!extras.IsEmpty)
            {
                userPrefs = PreferenceManager.GetDefaultSharedPreferences(this);

                if(GoogleCloudMessaging.MessageTypeSendError.Equals(messageType))
                {
                    AndroidUtils.SendNotification("Speeching Error", "Error while sending message: " + extras.ToString(), typeof(MainActivity), this);
                }
                else if(GoogleCloudMessaging.MessageTypeDeleted.Equals(messageType))
                {
                    AndroidUtils.SendNotification("Speeching Messages", "Deleted messages on the server", typeof(MainActivity), this);
                }
                else if(GoogleCloudMessaging.MessageTypeMessage.Equals(messageType))
                {
                    string notifType = extras.GetString("notifType");
                    lastType = notifType;
                    PrepClient();

                    // Choose what to do depending on the message type
                    switch (notifType)
                    {
                        case "notification" :
                            if (userPrefs.GetBoolean("prefNotifMessage", true))
                            {
                                // The user wants to receive notifications
                                AndroidUtils.SendNotification(extras.GetString("title"), extras.GetString("message"), typeof(LoginActivity), this);
                            }
                            break;
                        case "locationReminder" :
                            if (userPrefs.GetBoolean("prefNotifMessage", true))
                            {
                                // The user wants to receive notifications
                                ShowReminder();
                            }
                            break;
                        case "newFences" :
                            if (userPrefs.GetBoolean("prefNotifGeofence", true))
                            {
                                // The user wants to have geofences enabled
                                BuildFences(extras.GetString("fences"));
                            }
                            break;
                        case "newActivities" :
                            FetchNewContent();
                            break;
                    }
                   
                }
            }
        }
开发者ID:GSDan,项目名称:Speeching_Client,代码行数:58,代码来源:GCMService.cs

示例10: OnSharedPreferenceChanged

        public void OnSharedPreferenceChanged(ISharedPreferences sharedPreferences, string key)
        {
            switch (key)
            {
                case PreferenceKeys.Timeout:
                    Runner.Instance.Options.Timeout = sharedPreferences.GetInt(key, Runner.Instance.Options.Timeout);
                    break;
                case PreferenceKeys.SaveNamespaces:
                    if (!sharedPreferences.GetBoolean(key, false))
                        resetSavedNamespaces();

                    break;
                case PreferenceKeys.MultiLineEditing:
                    CSharpToGoApplication.Options.MultiLineEditing = sharedPreferences.GetBoolean(key, CSharpToGoApplication.Options.MultiLineEditing);

                    break;
                case PreferenceKeys.DoubleEnter:
                    CSharpToGoApplication.Options.DoubleEnterToExecute = sharedPreferences.GetBoolean(key, CSharpToGoApplication.Options.DoubleEnterToExecute);

                    break;
            }
        }
开发者ID:jorik041,项目名称:CSharpToGo,代码行数:22,代码来源:SharedPreferenceChangeListener.cs

示例11: Initialize

		public void Initialize(ISharedPreferences pref){
			preference = pref;	
			
			leftPort = StringToMotorPort(preference.GetString("leftPort", "Motor A"));
			rightPort = StringToMotorPort(preference.GetString("rightPort", "Motor C"));
			additionalPort = StringToMotorPort(preference.GetString("additionalPort", "Motor B"));
			
			reverseLeft =  preference.GetBoolean("reverseLeft", false);
			reverseRight = preference.GetBoolean("reverseRight", false);
			reverseAdditional = preference.GetBoolean("reverseAdditional", false);
			
			sendVehicleDataToMailbox = preference.GetBoolean("sendVehicleDataToMailbox", false);
			sensorValueToSpeech = preference.GetBoolean("sensorValueToSpeech", true);
			deviceName = preference.GetString("deviceName", "");
			type = StringToBrickType(preference.GetString("brickType", "EV3"));
			vehicleMailbox = StringToMailbox(preference.GetString("vehicleMailbox", "Mailbox 0"));
			degreeOffset = StringToDegreeOffset(preference.GetString("degreeOffset", "Up"));
			
			sensor1 = preference.GetString("sensor1", "None");
			sensor2 = preference.GetString("sensor2", "None");
			sensor3 = preference.GetString("sensor3", "None");
			sensor4 = preference.GetString("sensor4", "None");
		}
开发者ID:seipekm,项目名称:MonoBrick-Communication-Software,代码行数:23,代码来源:Settings.cs

示例12: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);
            SetContentView (Resource.Layout.welcome);

            prefs = GetPreferences (FileCreationMode.Append);
            firstTime = prefs.GetBoolean (FIRST, true);
            if (firstTime) {
                MakeQuestionDB ();
                MakeScoreDB ();
                editor = prefs.Edit ();
                editor.PutBoolean (FIRST, false);
                editor.Commit ();

            }

            Button button = FindViewById<Button> (Resource.Id.btnStarQuiz);
            button.Click += delegate {
                StartActivity (typeof(QuizActivity));
                Finish ();
            };
        }
开发者ID:bny-mobile,项目名称:QuizData,代码行数:22,代码来源:Activity1.cs

示例13: OnRequestPermissionsResult

        public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Android.Content.PM.Permission[] grantResults)
        {
            if (requestCode == FINGERPRINT_PERMISSION_REQUEST_CODE && grantResults[0] == Android.Content.PM.Permission.Granted) {
                SetContentView (Resource.Layout.activity_main);
                var purchaseButton = FindViewById<Button> (Resource.Id.purchase_button);

                if (!mKeyguardManager.IsKeyguardSecure) {
                    purchaseButton.Enabled = false;
                    // Show a message that the user hasn't set up a fingerprint or lock screen.
                    Toast.MakeText (this, "Secure lock screen hasn't set up.\n"
                        + "Go to 'Settings -> Security -> Fingerprint' to set up a fingerprint", ToastLength.Long).Show ();
                    return;
                }

                mFingerprintManager = (FingerprintManager)GetSystemService (Context.FingerprintService);
                if (!mFingerprintManager.HasEnrolledFingerprints) {
                    purchaseButton.Enabled = false;
                    // This happens when no fingerprints are registered.
                    Toast.MakeText (this, "Go to 'Settings -> Security -> Fingerprint' " +
                        "and register at least one fingerprint", ToastLength.Long).Show ();
                    return;
                }

                CreateKey ();
                purchaseButton.Enabled = true;
                purchaseButton.Click += (sender, e) => {
                    // Show the fingerprint dialog. The user has the option to use the fingerprint with
                    // crypto, or you can fall back to using a server-side verified password.
                    FindViewById (Resource.Id.confirmation_message).Visibility = ViewStates.Gone;
                    FindViewById (Resource.Id.encrypted_message).Visibility = ViewStates.Gone;

                    mFragment = new FingerprintAuthenticationDialogFragment ();
                    mSharedPreferences = this.GetPreferences (FileCreationMode.Private);

                    if (InitCipher ()) {
                        mFragment.SetCryptoObject (new FingerprintManager.CryptoObject (mCipher));
                        var useFingerprintPreference = mSharedPreferences.GetBoolean (GetString (Resource.String.use_fingerprint_to_authenticate_key), true);
                        if (useFingerprintPreference) {
                            mFragment.SetStage (FingerprintAuthenticationDialogFragment.Stage.Fingerprint);
                        } else {
                            mFragment.SetStage (FingerprintAuthenticationDialogFragment.Stage.Password);
                        }
                        mFragment.Show (FragmentManager, DIALOG_FRAGMENT_TAG);
                    } else {
                        mFragment.SetCryptoObject (new FingerprintManager.CryptoObject (mCipher));
                        mFragment.SetStage (FingerprintAuthenticationDialogFragment.Stage.NewFingerprintEnrolled);
                        mFragment.Show (FragmentManager, DIALOG_FRAGMENT_TAG);
                    }
                };
            }
        }
开发者ID:CHANDAN145,项目名称:monodroid-samples,代码行数:51,代码来源:MainActivity.cs

示例14: GetBool

 public static bool GetBool(ISharedPreferences prefs, string key, bool def = false)
 {
     return prefs.GetBoolean(key, def);
 }
开发者ID:fubar-coder,项目名称:cryptrans,代码行数:4,代码来源:Preferences.cs

示例15: OnCreate

        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            _design.ApplyTheme();

            //use FlagSecure to make sure the last (revealed) character of the master password is not visible in recent apps
            if (PreferenceManager.GetDefaultSharedPreferences(this).GetBoolean(
                GetString(Resource.String.ViewDatabaseSecure_key), true))
            {
                Window.SetFlags(WindowManagerFlags.Secure, WindowManagerFlags.Secure);
            }

            Intent i = Intent;

            //only load the AppTask if this is the "first" OnCreate (not because of kill/resume, i.e. savedInstanceState==null)
            // and if the activity is not launched from history (i.e. recent tasks) because this would mean that
            // the Activity was closed already (user cancelling the task or task complete) but is restarted due recent tasks.
            // Don't re-start the task (especially bad if tak was complete already)
            if (Intent.Flags.HasFlag(ActivityFlags.LaunchedFromHistory))
            {
                AppTask = new NullTask();
            }
            else
            {
                AppTask = AppTask.GetTaskInOnCreate(savedInstanceState, Intent);
            }

            String action = i.Action;

            _prefs = PreferenceManager.GetDefaultSharedPreferences(this);
            _rememberKeyfile = _prefs.GetBoolean(GetString(Resource.String.keyfile_key), Resources.GetBoolean(Resource.Boolean.keyfile_default));

            _ioConnection = new IOConnectionInfo();

            if (action != null && action.Equals(ViewIntent))
            {
                if (!GetIocFromViewIntent(i)) return;
            }
            else if ((action != null) && (action.Equals(Intents.StartWithOtp)))
            {
                if (!GetIocFromOtpIntent(savedInstanceState, i)) return;
                _keepPasswordInOnResume = true;
            }
            else
            {
                SetIoConnectionFromIntent(_ioConnection, i);
                var keyFileFromIntent = i.GetStringExtra(KeyKeyfile);
                if (keyFileFromIntent != null)
                {
                    Kp2aLog.Log("try get keyfile from intent");
                    _keyFileOrProvider = IOConnectionInfo.SerializeToString(IOConnectionInfo.FromPath(keyFileFromIntent));
                    Kp2aLog.Log("try get keyfile from intent ok");
                }
                else
                {
                    _keyFileOrProvider = null;
                }
                _password = i.GetStringExtra(KeyPassword) ?? "";
                if (string.IsNullOrEmpty(_keyFileOrProvider))
                {
                    _keyFileOrProvider = GetKeyFile(_ioConnection.Path);
                }
                if ((!string.IsNullOrEmpty(_keyFileOrProvider)) || (_password != ""))
                {
                    _keepPasswordInOnResume = true;
                }
            }

            if (App.Kp2a.GetDb().Loaded && App.Kp2a.GetDb().Ioc != null &&
                App.Kp2a.GetDb().Ioc.GetDisplayName() != _ioConnection.GetDisplayName())
            {
                // A different database is currently loaded, unload it before loading the new one requested
                App.Kp2a.LockDatabase(false);
            }

            SetContentView(Resource.Layout.password);
            InitializeFilenameView();

            if (KeyProviderType == KeyProviders.KeyFile)
            {
                UpdateKeyfileIocView();
            }

            FindViewById<EditText>(Resource.Id.password).TextChanged +=
                (sender, args) =>
                {
                    _password = FindViewById<EditText>(Resource.Id.password).Text;
                    UpdateOkButtonState();
                };
            FindViewById<EditText>(Resource.Id.password).EditorAction += (sender, args) =>
                {
                    if ((args.ActionId == ImeAction.Done) || ((args.ActionId == ImeAction.ImeNull) && (args.Event.Action == KeyEventActions.Down)))
                        OnOk();
                };

            FindViewById<EditText>(Resource.Id.pass_otpsecret).TextChanged += (sender, args) => UpdateOkButtonState();

            EditText passwordEdit = FindViewById<EditText>(Resource.Id.password);
            passwordEdit.Text = _password;
            passwordEdit.RequestFocus();
//.........这里部分代码省略.........
开发者ID:pythe,项目名称:wristpass,代码行数:101,代码来源:PasswordActivity.cs


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