Android Open Source - legacy_bluetrack Settings Activity






From Project

Back to project page legacy_bluetrack.

License

The source code is released under:

GNU General Public License

If you think the Android project legacy_bluetrack listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.jonblack.bluetrack.activities;
/*w w w . j  a v  a2 s  . co  m*/
import org.jonblack.bluetrack.R;

import com.actionbarsherlock.app.SherlockPreferenceActivity;

import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle;
import android.preference.EditTextPreference;
import android.preference.PreferenceManager;

public class SettingsActivity extends SherlockPreferenceActivity implements OnSharedPreferenceChangeListener
{
    private EditTextPreference mScanDelayPreference;
    
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
      super.onCreate(savedInstanceState);
      
      // Load the preference from xml
      addPreferencesFromResource(R.xml.preferences);
      
      // Get references to preferences
      mScanDelayPreference = (EditTextPreference) getPreferenceScreen().findPreference("pref_tracking_scan_delay");
    }
    
    @Override
    public void onResume()
    {
      super.onResume();
      
      SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
      
      // Set initial values by calling the preference change handler manually.
      onSharedPreferenceChanged(sharedPrefs, "pref_tracking_scan_delay");
      
      // Register preference change listener
      sharedPrefs.registerOnSharedPreferenceChangeListener(this);
    }
    
    @Override
    public void onPause()
    {
      super.onPause();
      
      SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
      sharedPrefs.unregisterOnSharedPreferenceChangeListener(this);
    }
    
    @Override
    public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
                                          String key)
    {
      // A preference value has changed. Some options show their value in the
      // summary. If one of those options has changed, update the summary.
      if (key.equals("pref_tracking_scan_delay"))
      {
        int scanDelay = Integer.parseInt(sharedPreferences.getString(key, ""));
        String summary = getString(R.string.pref_tracking_scan_delay, scanDelay);
        mScanDelayPreference.setSummary(summary);
      }
    }
}




Java Source Code List

org.jonblack.bluetrack.BluetoothClassLookup.java
org.jonblack.bluetrack.BluetrackIdentifiers.java
org.jonblack.bluetrack.DeviceDiscovery.java
org.jonblack.bluetrack.Device.java
org.jonblack.bluetrack.Session.java
org.jonblack.bluetrack.activities.DevicesFragment.java
org.jonblack.bluetrack.activities.LiveTrackingFragment.java
org.jonblack.bluetrack.activities.MainActivity.java
org.jonblack.bluetrack.activities.SessionFragment.java
org.jonblack.bluetrack.activities.SettingsActivity.java
org.jonblack.bluetrack.adapters.DeviceCursorAdapter.java
org.jonblack.bluetrack.adapters.LiveTrackingCursorAdapter.java
org.jonblack.bluetrack.adapters.SessionCursorAdapter.java
org.jonblack.bluetrack.services.BluetoothLogService.java
org.jonblack.bluetrack.storage.BluetrackContentProvider.java
org.jonblack.bluetrack.storage.BluetrackOpenHelper.java
org.jonblack.bluetrack.storage.DeviceDiscoveryTable.java
org.jonblack.bluetrack.storage.DeviceTable.java
org.jonblack.bluetrack.storage.SessionTable.java