Android PreferenceManager - 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 PreferenceManager class.

This code example shows how to use the following methods:getBroadcast, getSystemService, getDefaultSharedPreferences
  @Override 
  public void onReceive(Context context, Intent intent) {
    Log.w("DirectoryUpdateReceiver", "Initiating scheduled directory update...");
 
    try { 
      SignalingSocket signalingSocket = new SignalingSocket(context);
      DirectoryResponse response      = signalingSocket.getNumberFilter();
 
      if (response != null) {
        NumberFilter filter = new NumberFilter(response.getFilter(), response.getHashCount());
        filter.serializeToFile(context);
      } 
    } catch (SignalingException se) {
      Log.w("DirectoryUpdateReceiver", se);
    } catch (Exception e) {
      Log.w("DirectoryUpdateReceiver", e);
      return; 
    } 
 
    scheduleDirectoryUpdate(context);

9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:startService, getDefaultSharedPreferences
import android.preference.PreferenceManager; 
 
public class NetworkReceiver extends BroadcastReceiver {
  @Override 
  public void onReceive(Context context, Intent intent) {
    SharedPreferences prefs=
        PreferenceManager.getDefaultSharedPreferences(context);
 
    if (SyncService.isSyncNeeded(context, prefs)) {
      context.startService(new Intent(context, SyncService.class));
    } 
  } 
} 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:openFileOutput, getDefaultSharedPreferences
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getWindow, getWindowManager, getDefaultSharedPreferences
        super.onCreate(savedInstanceState);
    } 
 
    public static void setBackgroundImage (Activity activity)
    { 
        SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(activity);
        //int themeId = settings.getInt("theme", R.style.Theme_Gibberbot_Light); 
        boolean themeDark = settings.getBoolean("themeDark", false);
        String themebg = settings.getString("pref_background", "");
         
         
        if (themebg != null && themebg.length() > 0)
        { 
 
            File fileThemeBg = new File(themebg);
            if (!fileThemeBg.exists())
                return; 
             
            if (mThemeBg == null || (!mThemeBg.equals(themebg)))
            { 

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:startService, getDefaultSharedPreferences
import android.preference.PreferenceManager; 
 
public class NetworkReceiver extends BroadcastReceiver {
  @Override 
  public void onReceive(Context context, Intent intent) {
    SharedPreferences prefs=
        PreferenceManager.getDefaultSharedPreferences(context);
 
    if (SyncService.isSyncNeeded(context, prefs)) {
      context.startService(new Intent(context, SyncService.class));
    } 
  } 
} 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getService, getSystemService, getDefaultSharedPreferences
        } 
	} 
	 
	public static void setAlarm(Context context) {
		PendingIntent alarmSender;
		alarmSender = PendingIntent.getService(context, 0, new Intent(context, AutoRefreshService.class), PendingIntent.FLAG_UPDATE_CURRENT);
		SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
        boolean autoUpdatesEnabled = prefs.getBoolean("autoupdates_enabled", true);
        Integer refreshRate = Integer.parseInt(prefs.getString("refresh_rate", "0")); 
        AlarmManager am = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
        if (!autoUpdatesEnabled) {
        	am.cancel(alarmSender);
        } 
        else { 
	        long firstTime = SystemClock.elapsedRealtime();
	        int secondsInMinute = 60;
	        if (prefs.getBoolean("debug_mode", false) && prefs.getBoolean("debug_refreshrate_in_seconds", false)) {
	            secondsInMinute = 1;
	        } 
	        am.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, firstTime+refreshRate*secondsInMinute*1000, refreshRate*secondsInMinute*1000, alarmSender);

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getApplicationContext, getDefaultSharedPreferences
 
	private SharedPreferences appSettings;
 
	private boolean shouldStartService(Context context) {
		this.appSettings = PreferenceManager
				.getDefaultSharedPreferences(context.getApplicationContext());
		return this.appSettings.getBoolean("doAutoSync", false);
	} 
 
	@Override 
	public void onReceive(Context context, Intent intent) {
		if (this.shouldStartService(context)) {
			SyncService.startAlarm(context);
		} 
		 
		Intent calIntent = new Intent(context, CalendarSyncService.class);
		calIntent.putExtra(CalendarSyncService.FILELIST, new String[] {});
		context.startService(calIntent);
	} 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getBroadcast, getSystemService, getDefaultSharedPreferences
import android.preference.PreferenceManager; 
import java.util.Calendar; 
 
public class OnBootReceiver extends BroadcastReceiver {
  public static void setAlarm(Context ctxt) {
    AlarmManager mgr=(AlarmManager)ctxt.getSystemService(Context.ALARM_SERVICE);
    Calendar cal=Calendar.getInstance();
    SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(ctxt);
    String time=prefs.getString("alarm_time", "12:00");
     
    cal.set(Calendar.HOUR_OF_DAY, TimePreference.getHour(time));
    cal.set(Calendar.MINUTE, TimePreference.getMinute(time));
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);
     
    if (cal.getTimeInMillis()<System.currentTimeMillis()) {
      cal.add(Calendar.DAY_OF_YEAR, 1);
    } 
     
    mgr.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(),

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getDefaultSharedPreferences
    public SettingsBackend(Context context) {
    	this(context, null);
    } 
     
    public SettingsBackend(Context context, SharedPreferences preferences) {
    	super(context, "app-preferences");
    	if (preferences == null) {
    		preferences = PreferenceManager.getDefaultSharedPreferences(context);
    	} 
        mPreferences = preferences;
    } 
 
    @Override 
    public void onLoad() { 
    	super.onLoad(); 
        mKirinHelper.jsMethod("mergeOrOverwrite", mPreferences.getAll());
        mKirinHelper.jsMethod("resetEnvironment"); 
    } 
     
    /* (non-Javadoc) 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:startActivity, getDefaultSharedPreferences
	public void onReceive(Context context, Intent intent) {
		 
		// Received intent only when the system boot is completed 
		Log.d(TAG, "onReceiveIntent");
 
		SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
		boolean startupOnBoot = sharedPreferences.getBoolean("setting_startup_onboot", false);
		if (startupOnBoot) {
			Intent activityIntent = new Intent(context, HomeActivity.class);
			activityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
			context.startActivity(activityIntent);
		} 
	} 
 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Android PreferenceManager Questions & Answers:

See Code Examples for Android PreferenceManager Methods: