Android SwitchPreference - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android SwitchPreference class.

This code example shows how to use the following methods:
			((CheckBoxPreference) pref).setChecked(checked);
		} 
	} 
 
	public static Preference createTwoStatePreference(Context ctx) {
		return IS_ICS ? new SwitchPreference(ctx) : new CheckBoxPreference(ctx);
	} 
} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setEnabled, setChecked
 
	private void changDiagMode() { 
 
		try { 
			if (readDiagMode()) { 
				diagSwitch.setEnabled(false);
				execout.writeBytes("echo 0 > /sys/class/android_usb/android0/enable"
						+ "\n"); 
				execout.flush();
				execout.writeBytes("echo PDA > /sys/devices/tuna_otg/usb_sel"
						+ "\n"); 
				execout.flush();
				execout.writeBytes("echo 1 > /sys/class/android_usb/android0/enable"
						+ "\n"); 
				execout.flush();
			} else { 
				diagSwitch.setEnabled(false);
				execout.writeBytes("echo 0 > /sys/class/android_usb/android0/enable"
						+ "\n"); 
				execout.flush();

5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setSummary, isChecked
						this.getSystemService(Context.NOTIFICATION_SERVICE);
				notificationManager.cancelAll();
			} 
		} 
		if(pref == fast) {
			boolean value = fast.isChecked();
			if(value ==true) {
				fast.setSummary("Enabled");
				CMDProcessor.runSuCommand("busybox echo 1 > /sys/devices/platform/_battery/fast_charge"); 
			} 
			if(value==false) {
				fast.setSummary("Disabled");
				CMDProcessor.runSuCommand("busybox echo 0 > /sys/devices/platform/_battery/fast_charge"); 
			} 
		} 
 
		return false; 
	} 
 
	private void changegov(){ 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:isChecked
		case 1: 
			helper = new TimeTaskDBHelper(this);
			TimeTask task;
			String time = (String) timePreference.getSummary();
			String op = (String) opPreference.getSummary();
			int enable = (switchPreference.isChecked()) ? 1 : 0;
			if (time == null || op == null) {
				helper.close();
				return false; 
			} 
 
			if (add) {
				ArrayList<TimeTask> data = new ArrayList<TimeTask>();
				task = new TimeTask(time, op, enable);
				data.add(task);
				helper.insert(data);
			} else { 
				task = new TimeTask(id, time, op, enable);
				helper.update(task);
				TimeTaskFragment.adapter.notifyDataSetChanged(); 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:isChecked
		case 1: 
			helper = new EventTaskDBHelper(this);
			EventTask task;
			String event = (String) eventPreference.getSummary();
			String op = (String) opPreference.getSummary();
			int enable = (switchPreference.isChecked()) ? 1 : 0;
			if (event == null || op == null) {
				helper.close();
				return false; 
			} 
 
			if (add) {
				ArrayList<EventTask> data = new ArrayList<EventTask>();
				task = new EventTask(event, op, enable);
				data.add(task);
				helper.insert(data);
			} else { 
				task = new EventTask(id, event, op, enable);
				helper.update(task);
				EventTaskFragment.adapter.notifyDataSetChanged(); 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:isChecked
					Toast.makeText(getActivity(), "Service OFF", Toast.LENGTH_SHORT).show();
				//	catTaskService.removePreference(lInterval); 
					alarmManager.cancel(pendingIntent);
				} 
			} else if (preference == lInterval) {
				if (swchFetch.isChecked()) {
					long startTime = 0;
					if (newValue.equals("86400")) {
						Calendar midnight = Calendar.getInstance();
						midnight.set(Calendar.HOUR_OF_DAY, 0);
						midnight.set(Calendar.MINUTE, 0);
						midnight.set(Calendar.SECOND, 0);
						midnight.add(Calendar.DAY_OF_MONTH, 1);
						startTime = midnight.getTimeInMillis();
						toastText = "Every 24 Hours at 00:00";
					} else if (newValue.equals("10")) {
						toastText = "Every 10 Seconds starting Now";
					} else if (newValue.equals("60")) {
						toastText = "Every Minute starting Now";
					} else if (newValue.equals("900")) {
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:isChecked
		return view;
	} 
	 
	@SuppressLint("NewApi") 
	public boolean getIsChecked(){ 
		return s.isChecked();
	} 
} 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
		return root;
	} 
 
	@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
	public Preference createSyncDropboxSwitchPref(PreferenceCategory syncPrefCat) {
		return new SwitchPreference(this);
	} 
 
	protected void doSyncDropbox(Boolean isSync) {
		if (isSync) {
			this.dropboxHelper.getDropboxApi().getSession().startAuthentication(PreferencesActivity.this);
		} else { 
			this.dropboxHelper.doLogout();
		} 
	} 
 
} 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setChecked
	public boolean onPreferenceChange(Preference preference, Object value) {
		String stringValue = value.toString();
		 
		if (preference.getKey().equals(perf_service_switch)) {
			SwitchPreference service = (SwitchPreference) preference;
			service.setChecked((Boolean) value);
		} 
		{ 
			preference.setSummary(stringValue);
		} 
		 
		return true; 
	} 
 
	@Override 
	public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
			String key) {
		// TODO Auto-generated method stub 
		if (key.equals(perf_service_switch))
			this.onPreferenceChange(service_switch,
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Android SwitchPreference Questions & Answers:

See Code Examples for Android SwitchPreference Methods: