Java Code Examples for android.preference.PreferenceManager

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project andlytics, under directory /src/com/github/andlyticsproject/.

Source file: PreferenceActivity.java

  18 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  PreferenceManager prefMgr=getPreferenceManager();
  prefMgr.setSharedPreferencesName(Preferences.PREF);
  addPreferencesFromResource(R.xml.preferences);
  getPreferenceScreen().findPreference(Preferences.AUTOSYNC_PERIOD).setOnPreferenceChangeListener(this);
  accountListPrefCat=(PreferenceCategory)getPreferenceScreen().findPreference("prefCatAccountSpecific");
  buildAccountsList();
  for (int i=0; i < getPreferenceScreen().getPreferenceCount(); i++) {
    initSummary(getPreferenceScreen().getPreference(i));
  }
}
 

Example 2

From project android-client, under directory /xwiki-android-client/src/org/xwiki/android/client/blog/.

Source file: BlogPrefernces.java

  18 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  PreferenceManager pm=getPreferenceManager();
  pm.setSharedPreferencesName("preference_blog");
  addPreferencesFromResource(R.xml.preference_blog);
}
 

Example 3

From project aksunai, under directory /src/org/androidnerds/app/aksunai/preferences/.

Source file: Preferences.java

  17 
vote

@Override public void onCreate(Bundle icicle){
  super.onCreate(icicle);
  PreferenceManager manager=getPreferenceManager();
  manager.setSharedPreferencesName("aksunai-prefs");
  manager.setSharedPreferencesMode(MODE_WORLD_WRITEABLE);
  this.addPreferencesFromResource(resourceId());
  Preference p=findPreference("pref_large_font_label");
  if (p != null) {
    p.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener(){
      public boolean onPreferenceChange(      Preference p,      Object newObjValue){
        Boolean newValue=(Boolean)newObjValue;
        if (newValue == null) {
          return false;
        }
        return true;
      }
    }
);
  }
}
 

Example 4

From project androidpn, under directory /androidpn-client/src/org/androidpn/client/.

Source file: NotificationSettingsActivity.java

  17 
vote

private PreferenceScreen createPreferenceHierarchy(){
  Log.d(LOGTAG,"createSettingsPreferenceScreen()...");
  PreferenceManager preferenceManager=getPreferenceManager();
  preferenceManager.setSharedPreferencesName(Constants.SHARED_PREFERENCE_NAME);
  preferenceManager.setSharedPreferencesMode(Context.MODE_PRIVATE);
  PreferenceScreen root=preferenceManager.createPreferenceScreen(this);
  CheckBoxPreference notifyPref=new CheckBoxPreference(this);
  notifyPref.setKey(Constants.SETTINGS_NOTIFICATION_ENABLED);
  notifyPref.setTitle("Notifications Enabled");
  notifyPref.setSummaryOn("Receive push messages");
  notifyPref.setSummaryOff("Do not receive push messages");
  notifyPref.setDefaultValue(Boolean.TRUE);
  notifyPref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener(){
    public boolean onPreferenceChange(    Preference preference,    Object newValue){
      boolean checked=Boolean.valueOf(newValue.toString());
      if (checked) {
        preference.setTitle("Notifications Enabled");
      }
 else {
        preference.setTitle("Notifications Disabled");
      }
      return true;
    }
  }
);
  CheckBoxPreference soundPref=new CheckBoxPreference(this);
  soundPref.setKey(Constants.SETTINGS_SOUND_ENABLED);
  soundPref.setTitle("Sound");
  soundPref.setSummary("Play a sound for notifications");
  soundPref.setDefaultValue(Boolean.TRUE);
  CheckBoxPreference vibratePref=new CheckBoxPreference(this);
  vibratePref.setKey(Constants.SETTINGS_VIBRATE_ENABLED);
  vibratePref.setTitle("Vibrate");
  vibratePref.setSummary("Vibrate the phone for notifications");
  vibratePref.setDefaultValue(Boolean.TRUE);
  root.addPreference(notifyPref);
  root.addPreference(soundPref);
  root.addPreference(vibratePref);
  return root;
}
 

Example 5

From project 2Degrees-Toolbox, under directory /Toolbox/src/biz/shadowservices/DegreesToolbox/.

Source file: AbstractWidgetProvider.java

  15 
vote

static public void setAlarm(Context context){
  SharedPreferences sp=PreferenceManager.getDefaultSharedPreferences(context);
  long interval;
  String stringInterval=sp.getString("updateFreq","half_day");
  if (stringInterval.equals("hour")) {
    Log.d(TAG,"Hourly updates");
    interval=AlarmManager.INTERVAL_HOUR;
  }
 else   if (stringInterval.equals("half_day")) {
    Log.d(TAG,"Half day updates");
    interval=AlarmManager.INTERVAL_HALF_DAY;
  }
 else   if (stringInterval.equals("day")) {
    Log.d(TAG,"daily updates");
    interval=AlarmManager.INTERVAL_DAY;
  }
 else {
    Log.d(TAG,"other interval??? - using half day");
    interval=AlarmManager.INTERVAL_HALF_DAY;
  }
  Intent intent=new Intent("biz.shadowservices.DegreesToolbox.WIDGET_UPDATE");
  PendingIntent pendingIntent=PendingIntent.getBroadcast(context,0,intent,0);
  AlarmManager alarmManager=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
  Calendar calendar=Calendar.getInstance();
  calendar.setTimeInMillis(System.currentTimeMillis());
  calendar.add(Calendar.MINUTE,10);
  Log.d(TAG,"Setting alarm");
  alarmManager.setInexactRepeating(AlarmManager.RTC,calendar.getTimeInMillis(),interval,pendingIntent);
}
 

Example 6

From project abalone-android, under directory /src/com/bytopia/abalone/.

Source file: SelectLayoutActivity.java

  15 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  layouts=new ArrayList<Layout>();
  for (  String layout : getResources().getStringArray(R.array.game_layouts)) {
    String tempAi="com.bytopia.abalone.mechanics." + layout;
    try {
      Class layoutClass=Class.forName(tempAi);
      Layout l=(Layout)layoutClass.newInstance();
      layouts.add(l);
    }
 catch (    Exception e1) {
      e1.printStackTrace();
    }
  }
  setContentView(R.layout.layout_selecting);
  boardView=new BoardView(getApplicationContext()){
    @Override public boolean onTouchEvent(    MotionEvent e){
      if (e.getAction() == MotionEvent.ACTION_UP) {
        String name=layouts.get(index).getClass().getName();
        SharedPreferences preferences=PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
        preferences.edit().putString("layout",name).commit();
        finish();
      }
      return true;
    }
  }
;
  prev=(Button)findViewById(R.id.slect_layout_prev);
  next=(Button)findViewById(R.id.slect_layout_next);
  refrashLayout();
  LinearLayout linearLayout=(LinearLayout)findViewById(R.id.layout_selecting_layout);
  linearLayout.addView(boardView);
}
 

Example 7

From project Airports, under directory /src/com/nadmm/airports/afd/.

Source file: AirportDetailsActivity.java

  15 
vote

@Override public void onCreate(Bundle savedInstanceState){
  mMetarFilter=new IntentFilter();
  mMetarFilter.addAction(NoaaService.ACTION_GET_METAR);
  mMetarReceiver=new BroadcastReceiver(){
    @Override public void onReceive(    Context context,    Intent intent){
      Metar metar=(Metar)intent.getSerializableExtra(NoaaService.RESULT);
      showWxInfo(metar);
      ++mWxUpdates;
      if (mWxUpdates == mAwosViews.size()) {
        mWxUpdates=0;
        stopRefreshAnimation();
      }
    }
  }
;
  SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(getActivity());
  mRadius=Integer.valueOf(prefs.getString(PreferencesActivity.KEY_LOCATION_NEARBY_RADIUS,"30"));
  mDafdFilter=new IntentFilter();
  mDafdFilter.addAction(DafdService.ACTION_GET_AFD);
  mDafdReceiver=new BroadcastReceiver(){
    @Override public void onReceive(    Context context,    Intent intent){
      handleDafdBroadcast(intent);
    }
  }
;
  super.onCreate(savedInstanceState);
}
 

Example 8

From project AlarmApp-Android, under directory /src/org/alarmapp/.

Source file: AlarmApp.java

  15 
vote

@Override public void onCreate(){
  ACRA.init(this);
  super.onCreate();
  instance=this;
  PreferenceManager.setDefaultValues(this,R.xml.preferences,false);
  if (isDebuggable()) {
    LogEx.info("Running in Debug mode");
  }
}
 

Example 9

From project AmDroid, under directory /AmDroid/src/main/java/com/jaeckel/amenoid/app/.

Source file: AmenoidApp.java

  15 
vote

@Override public void onCreate(){
  this.cache=new SimpleWebImageCache<ThumbnailBus,ThumbnailMessage>(null,null,101,bus);
  Config.init(getApplicationContext());
  DEVELOPER_MODE=getResources().getBoolean(R.bool.debuggable);
  if (getResources().getBoolean(R.bool.strict)) {
    StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites().detectNetwork().penaltyDropBox().penaltyLog().build());
  }
  super.onCreate();
  prefs=PreferenceManager.getDefaultSharedPreferences(this);
  amenTypeThin=Typeface.createFromAsset(getAssets(),"fonts/AmenTypeThin.ttf");
  amenTypeBold=Typeface.createFromAsset(getAssets(),"fonts/AmenTypeBold.ttf");
  instance=this;
  builder=new AlertDialog.Builder(this);
  Log.v(TAG,"onCreate");
  final String authToken=readAuthTokenFromPrefs(prefs);
  final User me=readMeFromPrefs(prefs);
  String email=prefs.getString(Constants.PREFS_EMAIL,null);
  if (TextUtils.isEmpty(email)) {
    email=prefs.getString(Constants.PREFS_USER_NAME,"");
    if (!TextUtils.isEmpty(email) && email.contains("@")) {
      SharedPreferences.Editor editor=prefs.edit();
      editor.putString(Constants.PREFS_EMAIL,email);
      editor.commit();
    }
  }
  final String password=prefs.getString(Constants.PREFS_PASSWORD,null);
  if (authToken != null && me != null) {
    configureAmenService();
    service.init(authToken,me);
  }
 else   if (!TextUtils.isEmpty(email) && !TextUtils.isEmpty(password)) {
    getService(email,password);
  }
 else {
    getService();
  }
}
 

Example 10

From project android-api-demos, under directory /src/com/mobeelizer/demos/activities/.

Source file: BaseActivity.java

  15 
vote

/** 
 * {@inheritDoc}
 */
@Override protected void onCreate(final Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  mSharedPrefs=PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
  mSessionCode=mSharedPrefs.getString(SESSION_CODE,null);
  mUserType=UserType.valueOf(mSharedPrefs.getString(USER_TYPE,"A"));
  boolean initialized=mSharedPrefs.getBoolean(getClass().getSimpleName(),false);
  if (!initialized) {
    if (getHelpDialog() != null) {
      showDialog(getHelpDialog());
    }
    mSharedPrefs.edit().putBoolean(this.getClass().getSimpleName(),true).commit();
  }
}
 

Example 11

From project android-bankdroid, under directory /src/com/liato/bankdroid/adapters/.

Source file: AccountsAdapter.java

  15 
vote

public AccountsAdapter(Context context,boolean showHidden){
  this.context=context;
  this.banks=new ArrayList<Bank>();
  inflater=LayoutInflater.from(this.context);
  this.showHidden=showHidden;
  prefs=PreferenceManager.getDefaultSharedPreferences(context);
}
 

Example 12

From project android-client_1, under directory /src/com/buddycloud/content/.

Source file: RosterHelper.java

  15 
vote

static void recomputeUnread(String channel,BuddycloudProvider provider,SQLiteDatabase db){
  int unread=0;
  int unreadReplies=0;
{
    Cursor c=db.rawQuery(unreadCountQuery,new String[]{channel});
    if (c.moveToFirst()) {
      unread=c.getInt(0);
    }
    c.close();
  }
{
    SharedPreferences preferences=PreferenceManager.getDefaultSharedPreferences(provider.getContext());
    final String jid=preferences.getString("jid","");
    Cursor c=db.rawQuery(unreadReplyCountQuery,new String[]{channel,jid});
    if (c.moveToFirst()) {
      unreadReplies=c.getInt(0);
    }
    c.close();
  }
  ContentValues values=new ContentValues();
  values.put(Roster.UNREAD_MESSAGES,unread);
  values.put(Roster.UNREAD_REPLIES,unreadReplies);
  db.update(BuddycloudProvider.TABLE_ROSTER,values,Roster.JID + "=?",new String[]{channel});
}
 

Example 13

From project android-context, under directory /defunct/.

Source file: PrefsActivity.java

  15 
vote

public static int getDecimalPlaces(Context ctx){
  SharedPreferences settings=PreferenceManager.getDefaultSharedPreferences(ctx);
  String s=settings.getString(PREFS_DECIMAL_PLACES,new Integer(PREFS_DECIMAL_PLACES_DEFAULT).toString());
  int i;
  try {
    i=Integer.parseInt(s);
  }
 catch (  Exception e) {
    i=PREFS_DECIMAL_PLACES_DEFAULT;
  }
  return i;
}
 

Example 14

From project Android-File-Manager-Tablet, under directory /src/com/nexes/manager/tablet/.

Source file: DirContentActivity.java

  15 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  mContext=getActivity();
  mFileMang=new FileManager();
  mHandler=new EventHandler(mContext,mFileMang);
  mHandler.setOnWorkerThreadFinishedListener(this);
  if (savedInstanceState != null)   mData=mFileMang.getNextDir(savedInstanceState.getString("location"),true);
 else   mData=mFileMang.setHomeDir("/sdcard");
  mBackPathIndex=0;
  mHoldingFile=false;
  mHoldingZip=false;
  mActionModeSelected=false;
  mShowGrid="grid".equals((PreferenceManager.getDefaultSharedPreferences(mContext)).getString("pref_view","grid"));
  mShowThumbnails=PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean(SettingsActivity.PREF_THUMB_KEY,false);
  MainActivity.setOnSetingsChangeListener(this);
  DirListActivity.setOnChangeLocationListener(this);
}
 

Example 15

From project android-gltron, under directory /GlTron/src/com/glTron/Game/.

Source file: UserPrefs.java

  15 
vote

public void ReloadPrefs(){
  int cameraType;
  int gridIndex;
  int speedIndex;
  SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(mContext);
  cameraType=Integer.valueOf(prefs.getString("cameraPref",C_DEFAULT_CAM_TYPE));
switch (cameraType) {
case C_PREF_FOLLOW_CAM:
    mCameraType=Camera.CamType.E_CAM_TYPE_FOLLOW;
  break;
case C_PREF_FOLLOW_CAM_FAR:
mCameraType=Camera.CamType.E_CAM_TYPE_FOLLOW_FAR;
break;
case C_PREF_FOLLOW_CAM_CLOSE:
mCameraType=Camera.CamType.E_CAM_TYPE_FOLLOW_CLOSE;
break;
case C_PREF_BIRD_CAM:
mCameraType=Camera.CamType.E_CAM_TYPE_BIRD;
break;
default :
mCameraType=Camera.CamType.E_CAM_TYPE_FOLLOW;
break;
}
mMusic=prefs.getBoolean("musicOption",true);
mSFX=prefs.getBoolean("sfxOption",true);
mFPS=prefs.getBoolean("fpsOption",false);
mNumOfPlayers=Integer.valueOf(prefs.getString("playerNumber","4"));
gridIndex=Integer.valueOf(prefs.getString("arenaSize","1"));
mGridSize=C_GRID_SIZES[gridIndex];
speedIndex=Integer.valueOf(prefs.getString("gameSpeed","1"));
mSpeed=C_SPEED[speedIndex];
mPlayerColourIndex=Integer.valueOf(prefs.getString("playerBike","0"));
mDrawRecog=prefs.getBoolean("drawRecog",true);
}
 

Example 16

From project android-ocr, under directory /android/src/edu/sfsu/cs/orange/ocr/.

Source file: BeepManager.java

  15 
vote

public void updatePrefs(){
  SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(activity);
  playBeep=shouldBeep(prefs,activity);
  if (playBeep && mediaPlayer == null) {
    activity.setVolumeControlStream(AudioManager.STREAM_MUSIC);
    mediaPlayer=buildMediaPlayer(activity);
  }
}
 

Example 17

From project android-pedometer, under directory /src/name/bagi/levente/pedometer/preferences/.

Source file: EditMeasurementPreference.java

  15 
vote

protected void showDialog(Bundle state){
  mIsMetric=PreferenceManager.getDefaultSharedPreferences(getContext()).getString("units","imperial").equals("metric");
  setDialogTitle(getContext().getString(mTitleResource) + " (" + getContext().getString(mIsMetric ? mMetricUnitsResource : mImperialUnitsResource)+ ")");
  try {
    Float.valueOf(getText());
  }
 catch (  Exception e) {
    setText("20");
  }
  super.showDialog(state);
}
 

Example 18

From project android-shuffle, under directory /client/src/org/dodgybits/shuffle/android/preference/model/.

Source file: Preferences.java

  15 
vote

private static SharedPreferences getSharedPreferences(Context context){
  if (sPrefs == null) {
    sPrefs=PreferenceManager.getDefaultSharedPreferences(context);
  }
  return sPrefs;
}
 

Example 19

From project Android-Terminal-Emulator, under directory /src/jackpal/androidterm/.

Source file: RemoteInterface.java

  15 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(this);
  mSettings=new TermSettings(getResources(),prefs);
  Intent TSIntent=new Intent(this,TermService.class);
  startService(TSIntent);
  if (!bindService(TSIntent,mTSConnection,BIND_AUTO_CREATE)) {
    Log.e(TermDebug.LOG_TAG,"bind to service failed!");
    finish();
  }
}
 

Example 20

From project android-tether, under directory /src/og/android/tether/.

Source file: TetherApplication.java

  15 
vote

@Override public void onCreate(){
  Log.d(MSG_TAG,"Calling onCreate()");
  EasyTracker.getInstance().setContext(getApplicationContext());
  TetherApplication.singleton=this;
  this.coretask=new CoreTask();
  try {
    this.coretask.setPath(this.getApplicationContext().getFilesDir().getParent());
  }
 catch (  Exception e) {
    this.coretask.setPath("/data/data/og.android.tether");
  }
  Log.d(MSG_TAG,"Current directory is " + this.coretask.DATA_FILE_PATH);
  this.checkDirs();
  this.deviceType=Configuration.getDeviceType();
  this.interfaceDriver=Configuration.getWifiInterfaceDriver(this.deviceType);
  this.settings=PreferenceManager.getDefaultSharedPreferences(this);
  this.preferenceEditor=settings.edit();
  this.whitelist=this.coretask.new Whitelist();
  this.wpasupplicant=this.coretask.new WpaSupplicant();
  this.tiwlan=this.coretask.new TiWlanConf();
  this.tethercfg=this.coretask.new TetherConfig();
  this.tethercfg.read();
  this.dnsmasqcfg=this.coretask.new DnsmasqConfig();
  this.hostapdcfg=this.coretask.new HostapdConfig();
  this.btcfg=this.coretask.new BluetoothConfig();
  powerManager=(PowerManager)getSystemService(Context.POWER_SERVICE);
  wakeLock=powerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK,"TETHER_WAKE_LOCK");
  if (this.settings.getBoolean("facebook_connected",false)) {
    FBManager=new FBManager(this);
    FBManager.extendAccessTokenIfNeeded(this,null);
  }
  this.notificationManager=(NotificationManager)this.getSystemService(Context.NOTIFICATION_SERVICE);
  this.notification=new Notification(R.drawable.start_notification,"Open Garden Wifi Tether",System.currentTimeMillis());
  this.mainIntent=PendingIntent.getActivity(this,0,new Intent(this,MainActivity.class),0);
  this.accessControlIntent=PendingIntent.getActivity(this,1,new Intent(this,AccessControlActivity.class),0);
  requestStatsAlarm();
  updateDeviceParametersAdv();
  updateConfiguration();
}
 

Example 21

From project android-thaiime, under directory /latinime/src/com/android/inputmethod/deprecated/.

Source file: VoiceProxy.java

  15 
vote

private void reallyStartListening(boolean swipe){
  if (!VOICE_INSTALLED) {
    return;
  }
  if (!mHasUsedVoiceInput) {
    SharedPreferences.Editor editor=PreferenceManager.getDefaultSharedPreferences(mService).edit();
    editor.putBoolean(PREF_HAS_USED_VOICE_INPUT,true);
    SharedPreferencesCompat.apply(editor);
    mHasUsedVoiceInput=true;
  }
  if (!mLocaleSupportedForVoiceInput && !mHasUsedVoiceInputUnsupportedLocale) {
    SharedPreferences.Editor editor=PreferenceManager.getDefaultSharedPreferences(mService).edit();
    editor.putBoolean(PREF_HAS_USED_VOICE_INPUT_UNSUPPORTED_LOCALE,true);
    SharedPreferencesCompat.apply(editor);
    mHasUsedVoiceInputUnsupportedLocale=true;
  }
  mService.clearSuggestions();
  FieldContext context=makeFieldContext();
  mVoiceInput.startListening(context,swipe);
  switchToRecognitionStatusView(null);
}
 

Example 22

From project android-voip-service, under directory /src/main/java/net/chrislehmann/sipservice/service/.

Source file: SipService.java

  15 
vote

@Override public void onCreate(){
  messageLoop.start();
  PreferenceManager.setDefaultValues(this,R.xml.linphone_preferences,true);
  Hacks.dumpDeviceInformation();
  dumpInstalledLinphoneInformation();
  super.onCreate();
}
 

Example 23

From project android-xbmcremote, under directory /src/org/xbmc/android/remote/business/receiver/.

Source file: AutoStartReceiver.java

  15 
vote

@Override public void onReceive(Context context,Intent intent){
  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);
  }
}
 

Example 24

From project android-xbmcremote-sandbox, under directory /src/org/xbmc/android/remotesandbox/ui/phone/.

Source file: DashboardFragment.java

  15 
vote

/** 
 * Adds all our menu items to the grid.
 * @param menuGrid
 */
private void setupDashboardItems(GridView menuGrid){
  final ArrayList<HomeItem> homeItems=new ArrayList<HomeItem>();
  final SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(getActivity().getApplicationContext());
  if (prefs.getBoolean("setting_show_home_music",true)) {
    homeItems.add(new HomeItem(HOME_ACTION_MUSIC,R.drawable.home_ic_music,"Music","Listen to"));
  }
  menuGrid.setAdapter(new HomeAdapter(getActivity(),homeItems));
  menuGrid.setOnItemClickListener(mHomeMenuOnClickListener);
  menuGrid.setSelected(true);
  menuGrid.setSelection(0);
}
 

Example 25

From project AndroidBillingLibrary, under directory /AndroidBillingLibrary/src/net/robotmedia/billing/helper/.

Source file: AbstractBillingObserver.java

  15 
vote

public void onTransactionsRestored(){
  final SharedPreferences preferences=PreferenceManager.getDefaultSharedPreferences(activity);
  final Editor editor=preferences.edit();
  editor.putBoolean(KEY_TRANSACTIONS_RESTORED,true);
  editor.commit();
}
 

Example 26

From project AndroidExamples, under directory /ImgurExample/src/com/robertszkutak/androidexamples/imgurexample/.

Source file: ImgurExampleActivity.java

  15 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  pref=PreferenceManager.getDefaultSharedPreferences(this);
  token=pref.getString("IMGUR_OAUTH_TOKEN","");
  secret=pref.getString("IMGUR_OAUTH_TOKEN_SECRET","");
  if (token != null && token != "" && secret != null && secret != "") {
    auth=true;
    loggedin=true;
  }
 else   setAuthURL();
}
 

Example 27

From project AndroidLab, under directory /src/src/de/tubs/ibr/android/ldap/core/activities/.

Source file: PrefActivity.java

  15 
vote

@Override protected void onResume(){
  super.onResume();
  addPreferencesFromResource(R.xml.choose_account_preferences);
  ListPreference list=(ListPreference)findPreference("selectedAccount");
  AccountManager accManager=AccountManager.get(this);
  Account[] accounts=accManager.getAccountsByType(getString(R.string.ACCOUNT_TYPE));
  CharSequence[] entries=new CharSequence[accounts.length];
  for (int i=0; i < entries.length; i++) {
    entries[i]=accounts[i].name;
  }
  SharedPreferences mPrefs=PreferenceManager.getDefaultSharedPreferences(this);
  String accountname=mPrefs.getString("selectedAccount","");
  list.setEntries(entries);
  list.setEntryValues(entries);
  list.setTitle(accountname);
  mPrefs.registerOnSharedPreferenceChangeListener(this);
}
 

Example 28

From project androidquery, under directory /demo/src/com/androidquery/test/async/.

Source file: ServiceActivity.java

  15 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  PreferenceManager.getDefaultSharedPreferences(this).edit().putString("aqs.skip",null).commit();
  super.onCreate(savedInstanceState);
  type=getIntent().getStringExtra("type");
  if (type.equals("service_version_locale")) {
    aq.id(R.id.spinner).visible().setSelection(1).itemSelected(this,"localeSelected");
    aq.id(R.id.go_run).gone();
  }
  showResult("The update message is fetched from the 'Recent Changes' field of your Android Market's development console with the correponsing locale.",null);
}
 

Example 29

From project androidTileMapEditor_1, under directory /src/it/sineo/android/tileMapEditor/.

Source file: TiledMapView.java

  15 
vote

public void init(Context context){
  tileSize=context.getResources().getDimensionPixelSize(R.dimen.tiledMap_tile);
  gridPaint=new Paint(Paint.ANTI_ALIAS_FLAG);
  gridPaint.setColor(Color.WHITE);
  gridPaint.setStrokeWidth(1.5f);
  gridPaint.setAlpha(128);
  debugPaint=new Paint(gridPaint);
  debugPaint.setColor(Color.CYAN);
  debugPaint.setAlpha(255);
  SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext());
  mustDrawGrid=prefs.getBoolean(C.PREFS_MAP_SHOW_GRID,C.DEFAULT_MAP_SHOW_GRID);
  mustExportGrid=prefs.getBoolean(C.PREFS_EXPORT_SHOW_GRID,C.DEFAULT_EXPORT_SHOW_GRID);
  emptyTileColor=prefs.getInt(C.PREFS_MAP_COLOR_EMPTY_TILE,C.DEFAULT_MAP_COLOR_EMPTY_TILE);
  prefs.registerOnSharedPreferenceChangeListener(this);
  emptyTilePaint=new Paint(Paint.ANTI_ALIAS_FLAG);
  emptyTilePaint.setColor(emptyTileColor);
  emptyTilePaint.setStyle(Paint.Style.FILL_AND_STROKE);
  mapRect=new RectF(0,0,0,0);
  currentTouchPoint=new PointInfo();
  fingerDownPoint=new PointInfo();
}
 

Example 30

From project androidZenWriter, under directory /src/com/javaposse/android/zenwriter/.

Source file: AndroidZenWriterActivity.java

  15 
vote

protected void applyPreferences(){
  View top=findViewById(R.id.Top);
  SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(this);
  String backgroundImage=prefs.getString("backgroundpref","");
  Log.i("AndroidZenWriter:applyPreferences","BackgroundImage: " + backgroundImage);
  if (!backgroundImage.equals("")) {
    Drawable background=getDrawable(this,backgroundImage);
    if (background != null) {
      top.setBackgroundDrawable(background);
    }
  }
}
 

Example 31

From project android_7, under directory /src/org/immopoly/android/app/.

Source file: ImmopolyActivity.java

  15 
vote

/** 
 * Init the game
 */
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  mTracker=GoogleAnalyticsTracker.getInstance();
  mTracker.startNewSession(TrackingManager.UA_ACCOUNT,Const.ANALYTICS_INTERVAL,getApplicationContext());
  UserDataManager.instance.setActivity(this);
  setContentView(R.layout.immopoly_activity);
  mTabHost=(TabHost)findViewById(android.R.id.tabhost);
  mTabHost.setup();
  mTabManager=new TabManager(this,mTabHost,R.id.fragment_container);
  addTab(R.drawable.ic_tab_map,FRAGMENT_MAP,MapFragment.class,false);
  addTab(R.drawable.ic_tab_portfolio,"portfolio",PortfolioListFragment.class,false);
  addTab(R.drawable.ic_tab_portfolio,"portfolio_map",PortfolioMapFragment.class,true);
  addTab(R.drawable.ic_tab_profile,"profile",ProfileFragment.class,false);
  addTab(R.drawable.ic_tab_history,"history",HistoryFragment.class,false);
  FragmentManager.enableDebugLogging(true);
  if (savedInstanceState != null) {
    mTabHost.setCurrentTabByTag(savedInstanceState.getString("tab"));
  }
 else {
    SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(this);
    if (prefs.getBoolean("showFirstAid",true)) {
      new Handler().postDelayed(new Runnable(){
        @Override public void run(){
          new FirstAidDialog(ImmopolyActivity.this).show();
        }
      }
,4000);
    }
  }
  VERISONINFO=getVersionInfo();
}
 

Example 32

From project android_device_samsung_galaxys2, under directory /DeviceSettings/src/com/cyanogenmod/settings/device/.

Source file: Hspa.java

  15 
vote

/** 
 * Restore hspa setting from SharedPreferences. (Write to kernel.)
 * @param context       The context to read the SharedPreferences from
 */
public static void restore(Context context){
  if (!isSupported()) {
    return;
  }
  SharedPreferences sharedPrefs=PreferenceManager.getDefaultSharedPreferences(context);
  sendIntent(context,sharedPrefs.getString(DeviceSettings.KEY_HSPA,"23"));
}
 

Example 33

From project android_device_samsung_galaxys2_1, under directory /DeviceSettings/src/com/cyanogenmod/settings/device/.

Source file: Hspa.java

  15 
vote

/** 
 * Restore hspa setting from SharedPreferences. (Write to kernel.)
 * @param context       The context to read the SharedPreferences from
 */
public static void restore(Context context){
  if (!isSupported()) {
    return;
  }
  SharedPreferences sharedPrefs=PreferenceManager.getDefaultSharedPreferences(context);
  sendIntent(context,sharedPrefs.getString(DeviceSettings.KEY_HSPA,"23"));
}
 

Example 34

From project android_device_samsung_i777, under directory /DeviceSettings/src/com/cyanogenmod/settings/device/.

Source file: Hspa.java

  15 
vote

/** 
 * Restore hspa setting from SharedPreferences. (Write to kernel.)
 * @param context       The context to read the SharedPreferences from
 */
public static void restore(Context context){
  if (!isSupported()) {
    return;
  }
  SharedPreferences sharedPrefs=PreferenceManager.getDefaultSharedPreferences(context);
  sendIntent(context,sharedPrefs.getString(DeviceSettings.KEY_HSPA,"23"));
}
 

Example 35

From project android_packages_apps_CellBroadcastReceiver, under directory /src/com/android/cellbroadcastreceiver/.

Source file: CellBroadcastAlertService.java

  15 
vote

/** 
 * Filter out broadcasts on the test channels that the user has not enabled, and types of notifications that the user is not interested in receiving. This allows us to enable an entire range of message identifiers in the radio and not have to explicitly disable the message identifiers for test broadcasts. In the unlikely event that the default shared preference values were not initialized in CellBroadcastReceiverApp, the second parameter to the getBoolean() calls match the default values in res/xml/preferences.xml.
 * @param message the message to check
 * @return true if the user has enabled this message type; false otherwise
 */
private boolean isMessageEnabledByUser(CellBroadcastMessage message){
  if (message.isEtwsTestMessage()) {
    return PreferenceManager.getDefaultSharedPreferences(this).getBoolean(CellBroadcastSettings.KEY_ENABLE_ETWS_TEST_ALERTS,false);
  }
  if (message.isCmasMessage()) {
switch (message.getCmasMessageClass()) {
case SmsCbCmasInfo.CMAS_CLASS_EXTREME_THREAT:
      return PreferenceManager.getDefaultSharedPreferences(this).getBoolean(CellBroadcastSettings.KEY_ENABLE_CMAS_EXTREME_THREAT_ALERTS,true);
case SmsCbCmasInfo.CMAS_CLASS_SEVERE_THREAT:
    return PreferenceManager.getDefaultSharedPreferences(this).getBoolean(CellBroadcastSettings.KEY_ENABLE_CMAS_SEVERE_THREAT_ALERTS,true);
case SmsCbCmasInfo.CMAS_CLASS_CHILD_ABDUCTION_EMERGENCY:
  return PreferenceManager.getDefaultSharedPreferences(this).getBoolean(CellBroadcastSettings.KEY_ENABLE_CMAS_AMBER_ALERTS,true);
case SmsCbCmasInfo.CMAS_CLASS_REQUIRED_MONTHLY_TEST:
case SmsCbCmasInfo.CMAS_CLASS_CMAS_EXERCISE:
return PreferenceManager.getDefaultSharedPreferences(this).getBoolean(CellBroadcastSettings.KEY_ENABLE_CMAS_TEST_ALERTS,false);
default :
return true;
}
}
return true;
}
 

Example 36

From project android_packages_apps_cmparts, under directory /src/com/cyanogenmod/cmparts/activities/led/.

Source file: AdvancedActivity.java

  15 
vote

private void doReset(){
  SharedPreferences.Editor editor=PreferenceManager.getDefaultSharedPreferences(this).edit();
  editor.putString(CategoryActivity.KEY_CATEGORY_LIST,null);
  editor.commit();
  Settings.System.putString(getContentResolver(),Settings.System.NOTIFICATION_PACKAGE_COLORS,"");
  Toast.makeText(this,R.string.trackball_reset_all,Toast.LENGTH_LONG).show();
  setResult(RESULT_OK);
}
 

Example 37

From project android_packages_apps_FileManager, under directory /src/org/openintents/distribution/.

Source file: EulaOrNewVersion.java

  15 
vote

/** 
 * Test whether EULA has been accepted. Otherwise display EULA.
 * @return True if Eula needs to be shown.
 */
static boolean showEula(Activity activity){
  SharedPreferences sp=PreferenceManager.getDefaultSharedPreferences(activity);
  boolean accepted=sp.getBoolean(PREFERENCES_EULA_ACCEPTED,false);
  if (accepted) {
    if (debug)     Log.d(TAG,"Eula has been accepted.");
    return false;
  }
 else {
    if (debug)     Log.d(TAG,"Eula has not been accepted yet.");
    startForwardActivity(activity,EulaActivity.class);
    return true;
  }
}
 

Example 38

From project android_packages_apps_Gallery, under directory /src/com/android/camera/.

Source file: CameraSettings.java

  15 
vote

public static void initialCameraPictureSize(Context context,Parameters parameters){
  List<Size> supported=parameters.getSupportedPictureSizes();
  if (supported == null)   return;
  for (  String candidate : context.getResources().getStringArray(R.array.pref_camera_picturesize_entryvalues)) {
    if (setCameraPictureSize(candidate,supported,parameters)) {
      SharedPreferences.Editor editor=PreferenceManager.getDefaultSharedPreferences(context).edit();
      editor.putString(KEY_PICTURE_SIZE,candidate);
      editor.commit();
      return;
    }
  }
}
 

Example 39

From project android_packages_apps_Gallery2, under directory /src/com/android/gallery3d/app/.

Source file: PackagesMonitor.java

  15 
vote

private void onReceiveAsync(Context context,Intent intent){
  SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(context);
  int version=prefs.getInt(KEY_PACKAGES_VERSION,1);
  prefs.edit().putInt(KEY_PACKAGES_VERSION,version + 1).commit();
  String action=intent.getAction();
  String packageName=intent.getData().getSchemeSpecificPart();
  if (Intent.ACTION_PACKAGE_ADDED.equals(action)) {
    PicasaSource.onPackageAdded(context,packageName);
  }
 else   if (Intent.ACTION_PACKAGE_REMOVED.equals(action)) {
    PicasaSource.onPackageRemoved(context,packageName);
  }
 else   if (Intent.ACTION_PACKAGE_CHANGED.equals(action)) {
    PicasaSource.onPackageChanged(context,packageName);
  }
}
 

Example 40

From project android_packages_apps_phone, under directory /src/com/android/phone/.

Source file: CallFeaturesSetting.java

  15 
vote

public static CallFeaturesSetting getInstance(Context context){
  if (mInstance == null) {
    SharedPreferences pref=PreferenceManager.getDefaultSharedPreferences(context);
    mInstance=new CallFeaturesSetting();
    mInstance.init(context,pref);
  }
  return mInstance;
}
 

Example 41

From project android_packages_apps_QiblaCompass, under directory /src/com/farsitel/qiblacompass/activities/.

Source file: QiblaActivity.java

  15 
vote

/** 
 * Called when the activity is first created. 
 */
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
  registerListeners();
  Context context=getApplicationContext();
  perfs=PreferenceManager.getDefaultSharedPreferences(context);
  perfs.registerOnSharedPreferenceChangeListener(this);
  String gpsPerfKey=getString(R.string.gps_pref_key);
  TextView text1=(TextView)findViewById(R.id.location_text_line2);
  TextView text2=(TextView)findViewById(R.id.noLocationText);
  Typeface tf=Typeface.createFromAsset(getAssets(),"fonts/kufi.ttf");
  tf=Typeface.create(tf,Typeface.BOLD);
  if ("fa".equals(Locale.getDefault().getLanguage())) {
    text1.setTypeface(tf);
    text2.setTypeface(tf);
  }
 else {
    text1.setTypeface(Typeface.SERIF);
    text2.setTypeface(Typeface.SERIF);
  }
  boolean isGPS=false;
  try {
    isGPS=Boolean.parseBoolean(perfs.getString(gpsPerfKey,"false"));
  }
 catch (  ClassCastException e) {
    isGPS=perfs.getBoolean(gpsPerfKey,false);
  }
  if (!isGPS) {
    unregisterForGPS();
    useDefaultLocation(perfs,getString(R.string.state_location_pref_key));
  }
 else {
    registerForGPS();
    onGPSOn();
  }
  this.qiblaImageView=(ImageView)findViewById(R.id.arrowImage);
  this.compassImageView=(ImageView)findViewById(R.id.compassImage);
}
 

Example 42

From project android_packages_apps_SalvageParts, under directory /src/com/salvagemod/salvageparts/intents/.

Source file: CPUReceiver.java

  15 
vote

private void configureCPU(Context ctx){
  SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(ctx);
  if (prefs.getBoolean(PerformanceActivity.SOB_PREF,false) == false) {
    Log.i(TAG,"Restore disabled by user preference.");
    return;
  }
  String governor=prefs.getString(PerformanceActivity.GOV_PREF,null);
  String minFrequency=prefs.getString(PerformanceActivity.MIN_FREQ_PREF,null);
  String maxFrequency=prefs.getString(PerformanceActivity.MAX_FREQ_PREF,null);
  boolean noSettings=(governor == null) && (minFrequency == null) && (maxFrequency == null);
  if (noSettings) {
    Log.d(TAG,"No settings saved. Nothing to restore.");
  }
 else {
    List<String> governors=Arrays.asList(PerformanceActivity.readOneLine(PerformanceActivity.GOVERNORS_LIST_FILE).split(" "));
    List<String> frequencies=Arrays.asList(PerformanceActivity.readOneLine(PerformanceActivity.FREQ_LIST_FILE).split(" "));
    if (governor != null && governors.contains(governor)) {
      PerformanceActivity.writeOneLine(PerformanceActivity.GOVERNOR,governor);
    }
    if (maxFrequency != null && frequencies.contains(maxFrequency)) {
      PerformanceActivity.writeOneLine(PerformanceActivity.FREQ_MAX_FILE,maxFrequency);
    }
    if (minFrequency != null && frequencies.contains(minFrequency)) {
      PerformanceActivity.writeOneLine(PerformanceActivity.FREQ_MIN_FILE,minFrequency);
    }
    Log.d(TAG,"CPU settings restored.");
  }
}
 

Example 43

From project android_packages_apps_Superuser, under directory /src/com/noshufou/android/su/.

Source file: AppDetailsFragment.java

  15 
vote

private void setOptions(int option){
  ContentResolver cr=getActivity().getContentResolver();
  ContentValues values=new ContentValues();
  ;
switch (option) {
case MenuId.USE_APP_SETTINGS:
    mUseAppSettings=!mUseAppSettings;
  values.put(Apps.NOTIFICATIONS,mUseAppSettings ? null : mNotificationsEnabled);
values.put(Apps.LOGGING,mUseAppSettings ? null : mLoggingEnabled);
if (mUseAppSettings) {
SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(getActivity());
mNotificationsEnabled=prefs.getBoolean(Preferences.NOTIFICATIONS,true);
mLoggingEnabled=prefs.getBoolean(Preferences.LOGGING,true);
}
break;
case MenuId.NOTIFICATIONS:
mNotificationsEnabled=!mNotificationsEnabled;
values.put(Apps.NOTIFICATIONS,mNotificationsEnabled);
break;
case MenuId.LOGGING:
mLoggingEnabled=!mLoggingEnabled;
values.put(Apps.LOGGING,mLoggingEnabled);
break;
}
cr.update(ContentUris.withAppendedId(Apps.CONTENT_URI,mShownIndex),values,null,null);
getActivity().invalidateOptionsMenu();
}
 

Example 44

From project android_packages_inputmethods_LatinIME, under directory /java/src/com/android/inputmethod/deprecated/.

Source file: VoiceProxy.java

  15 
vote

private void reallyStartListening(boolean swipe){
  if (!VOICE_INSTALLED) {
    return;
  }
  if (!mHasUsedVoiceInput) {
    SharedPreferences.Editor editor=PreferenceManager.getDefaultSharedPreferences(mService).edit();
    editor.putBoolean(PREF_HAS_USED_VOICE_INPUT,true);
    SharedPreferencesCompat.apply(editor);
    mHasUsedVoiceInput=true;
  }
  if (!mLocaleSupportedForVoiceInput && !mHasUsedVoiceInputUnsupportedLocale) {
    SharedPreferences.Editor editor=PreferenceManager.getDefaultSharedPreferences(mService).edit();
    editor.putBoolean(PREF_HAS_USED_VOICE_INPUT_UNSUPPORTED_LOCALE,true);
    SharedPreferencesCompat.apply(editor);
    mHasUsedVoiceInputUnsupportedLocale=true;
  }
  mService.clearSuggestions();
  FieldContext context=makeFieldContext();
  mVoiceInput.startListening(context,swipe);
  switchToRecognitionStatusView(null);
}
 

Example 45

From project android_wallpaper_flier, under directory /src/fi/harism/wallpaper/flier/.

Source file: FlierService.java

  15 
vote

@Override public void onCreate(SurfaceHolder surfaceHolder){
  super.onCreate(surfaceHolder);
  mRenderer=new FlierRenderer(FlierService.this);
  mPreferences=PreferenceManager.getDefaultSharedPreferences(FlierService.this);
  mPreferences.registerOnSharedPreferenceChangeListener(this);
  mRenderer.setPreferences(mPreferences);
  mGLSurfaceView=new WallpaperGLSurfaceView(FlierService.this);
  mGLSurfaceView.setEGLContextClientVersion(2);
  mGLSurfaceView.setRenderer(mRenderer);
  mGLSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY);
  mGLSurfaceView.onPause();
}
 

Example 46

From project android_wallpaper_flowers, under directory /src/fi/harism/wallpaper/flowers/.

Source file: FlowerService.java

  15 
vote

@Override public void onCreate(SurfaceHolder surfaceHolder){
  super.onCreate(surfaceHolder);
  mRenderer=new FlowerRenderer(FlowerService.this);
  mPreferences=PreferenceManager.getDefaultSharedPreferences(FlowerService.this);
  mPreferences.registerOnSharedPreferenceChangeListener(this);
  mRenderer.setPreferences(mPreferences);
  mGLSurfaceView=new WallpaperGLSurfaceView(FlowerService.this);
  mGLSurfaceView.setEGLContextClientVersion(2);
  mGLSurfaceView.setRenderer(mRenderer);
  mGLSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY);
  mGLSurfaceView.onPause();
}
 

Example 47

From project andstatus, under directory /src/org/andstatus/app/data/.

Source file: MyPreferences.java

  15 
vote

/** 
 * @return DefaultSharedPreferences for this application
 */
public static SharedPreferences getDefaultSharedPreferences(){
  if (context == null) {
    Log.e(TAG,"getDefaultSharedPreferences - Was not initialized yet");
    return null;
  }
 else {
    return PreferenceManager.getDefaultSharedPreferences(context);
  }
}
 

Example 48

From project andtweet, under directory /src/com/xorcode/andtweet/data/.

Source file: AndTweetPreferences.java

  15 
vote

/** 
 * @return DefaultSharedPreferences for this application
 */
public static SharedPreferences getDefaultSharedPreferences(){
  if (context == null) {
    Log.e(TAG,"Was not initialized yet");
    return null;
  }
 else {
    return PreferenceManager.getDefaultSharedPreferences(context);
  }
}