Java Code Examples for android.preference.PreferenceActivity
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 creamed_glacier_app_settings, under directory /src/com/android/settings/applications/.
Source file: InstalledAppDetails.java

private void setIntentAndFinish(boolean finish,boolean appChanged){ if (localLOGV) Log.i(TAG,"appChanged=" + appChanged); Intent intent=new Intent(); intent.putExtra(ManageApplications.APP_CHG,appChanged); PreferenceActivity pa=(PreferenceActivity)getActivity(); pa.finishPreferencePanel(this,Activity.RESULT_OK,intent); }
Example 2
From project mythmote, under directory /src/tkj/android/homecontrol/mythmote/.
Source file: MythMotePreferences.java

@Override public boolean onOptionsItemSelected(MenuItem item){ final PreferenceActivity context=this; if (item.getItemId() == NEW_LOCATION_ID) { showLocationEditDialog(context,null); } else if (item.getItemId() == DELETE_LOCATION_ID) { showDeleteLocationList(context); } return true; }
Example 3
From project packages_apps_BlackICEControl, under directory /src/com/blackice/control/.
Source file: BlackICEPreferenceFragment.java

public boolean startFragment(Fragment caller,String fragmentClass,int requestCode,Bundle extras){ if (getActivity() instanceof PreferenceActivity) { PreferenceActivity preferenceActivity=(PreferenceActivity)getActivity(); preferenceActivity.startPreferencePanel(fragmentClass,extras,R.string.app_name,null,caller,requestCode); return true; } else { Log.w(TAG,"Parent isn't PreferenceActivity, thus there's no way to launch the " + "given Fragment (name: " + fragmentClass + ", requestCode: "+ requestCode+ ")"); return false; } }
Example 4
From project packages_apps_ROMControl, under directory /src/com/aokp/romcontrol/.
Source file: AOKPPreferenceFragment.java

public boolean startFragment(Fragment caller,String fragmentClass,int requestCode,Bundle extras){ if (getActivity() instanceof PreferenceActivity) { PreferenceActivity preferenceActivity=(PreferenceActivity)getActivity(); preferenceActivity.startPreferencePanel(fragmentClass,extras,R.string.app_name,null,caller,requestCode); return true; } else { Log.w(TAG,"Parent isn't PreferenceActivity, thus there's no way to launch the " + "given Fragment (name: " + fragmentClass + ", requestCode: "+ requestCode+ ")"); return false; } }
Example 5
From project platform_packages_apps_browser, under directory /src/com/android/browser/preferences/.
Source file: WebsiteSettingsFragment.java

private void finish(){ PreferenceActivity activity=(PreferenceActivity)getActivity(); if (activity != null) { activity.finishPreferencePanel(this,0,null); } }
Example 6
From project platform_packages_apps_settings, under directory /src/com/android/settings/applications/.
Source file: InstalledAppDetails.java

private void setIntentAndFinish(boolean finish,boolean appChanged){ if (localLOGV) Log.i(TAG,"appChanged=" + appChanged); Intent intent=new Intent(); intent.putExtra(ManageApplications.APP_CHG,appChanged); PreferenceActivity pa=(PreferenceActivity)getActivity(); pa.finishPreferencePanel(this,Activity.RESULT_OK,intent); }
Example 7
From project roboguice, under directory /roboguice/src/main/java/roboguice/inject/.
Source file: PreferenceListener.java

public void injectMembers(T instance){ final Context context=contextProvider.get(); if (!(context instanceof PreferenceActivity)) { throw new IllegalArgumentException(String.format("Can't inject a preference into a non-subclass of PreferenceAcvitity (%s)",field.getDeclaringClass())); } final PreferenceActivity activity=(PreferenceActivity)context; final String key=annotation.value(); Preference value=activity.findPreference(key); if (value == null && !field.isAnnotationPresent(Nullable.class)) { throw new NullPointerException(String.format("Can't inject null value into %s.%s when field is not @Nullable",field.getDeclaringClass(),field.getName())); } try { field.setAccessible(true); field.set(instance,value); } catch ( IllegalAccessException e) { throw new RuntimeException(e); } catch ( IllegalArgumentException f) { throw new IllegalArgumentException(String.format("Can't assign %s value %s to %s field %s",value != null ? value.getClass() : "(null)",value,field.getType(),field.getName())); } }
Example 8
From project rbb, under directory /src/com/btmura/android/reddit/app/.
Source file: AccountPreferenceFragment.java

private void handleRemoveAccount(){ AccountManager manager=AccountManager.get(getActivity()); String accountType=AccountAuthenticator.getAccountType(getActivity()); Account account=new Account(accountName,accountType); final AccountManagerFuture<Boolean> result=manager.removeAccount(account,null,null); new AsyncTask<Void,Void,Boolean>(){ @Override protected Boolean doInBackground( Void... params){ try { return result.getResult(); } catch ( OperationCanceledException e) { Log.e(TAG,"handleRemoveAccount",e); } catch ( AuthenticatorException e) { Log.e(TAG,"handleRemoveAccount",e); } catch ( IOException e) { Log.e(TAG,"handleRemoveAccount",e); } return false; } @Override protected void onPostExecute( Boolean result){ if (result) { PreferenceActivity prefActivity=(PreferenceActivity)getActivity(); prefActivity.finishPreferencePanel(AccountPreferenceFragment.this,Activity.RESULT_OK,new Intent()); } else { Toast.makeText(getActivity(),R.string.error,Toast.LENGTH_SHORT).show(); } } } .execute(); }
Example 9
From project android-thaiime, under directory /latinime/src/com/sugree/inputmethod/latin/.
Source file: LatinIME.java

protected void launchSettingsClass(Class<? extends PreferenceActivity> settingsClass){ handleClose(); Intent intent=new Intent(); intent.setClass(LatinIME.this,settingsClass); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); }
Example 10
From project android-xbmcremote, under directory /src/org/xbmc/android/remote/presentation/controller/.
Source file: HostPreference.java

@Override protected View onCreateView(final ViewGroup parent){ final ViewGroup view=(ViewGroup)super.onCreateView(parent); if (mHost != null) { ImageView btn=new ImageView(getContext()); btn.setImageResource(R.drawable.bubble_del_up); btn.setClickable(true); btn.setOnClickListener(new OnClickListener(){ public void onClick( View v){ AlertDialog.Builder builder=new AlertDialog.Builder(getContext()); builder.setMessage("Are you sure you want to delete the XBMC host \"" + mHost.name + "\"?"); builder.setPositiveButton("Yes!",new DialogInterface.OnClickListener(){ public void onClick( DialogInterface dialog, int which){ HostFactory.deleteHost(getContext(),mHost); ((PreferenceActivity)view.getContext()).getPreferenceScreen().removePreference(HostPreference.this); } } ); builder.setNegativeButton("Nah.",new DialogInterface.OnClickListener(){ public void onClick( DialogInterface dialog, int which){ dialog.cancel(); } } ); builder.create().show(); } } ); view.addView(btn); } return view; }
Example 11
From project android_packages_inputmethods_LatinIME, under directory /java/src/com/android/inputmethod/latin/.
Source file: LatinIME.java

protected void launchSettingsClass(Class<? extends PreferenceActivity> settingsClass){ handleClose(); Intent intent=new Intent(); intent.setClass(LatinIME.this,settingsClass); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); }
Example 12
From project andstatus, under directory /src/org/andstatus/app/data/.
Source file: MyPreferences.java

/** * @param pa Preference Activity * @param keyPreference android:key - Name of the preference key * @param entryValuesR android:entryValues * @param displayR Almost like android:entries but to show in the summary (may be the same as android:entries) * @param summaryR */ public static void showListPreference(PreferenceActivity pa,String keyPreference,int entryValuesR,int displayR,int summaryR){ String displayParm=""; ListPreference lP=(ListPreference)pa.findPreference(keyPreference); if (lP != null) { String[] k=pa.getResources().getStringArray(entryValuesR); String[] d=pa.getResources().getStringArray(displayR); displayParm=d[0]; String listValue=lP.getValue(); for (int i=0; i < k.length; i++) { if (listValue.equals(k[i])) { displayParm=d[i]; break; } } } else { displayParm=keyPreference + " was not found"; } MessageFormat sf=new MessageFormat(pa.getText(summaryR).toString()); lP.setSummary(sf.format(new Object[]{displayParm})); }
Example 13
From project droidparts, under directory /base/src/org/droidparts/inject/injector/.
Source file: ViewOrPreferenceInjector.java

static boolean inject(Context ctx,View root,InjectView ann,Object target,Field field){ boolean isView=View.class.isAssignableFrom(field.getType()); int viewOrPrefId=ann.value(); if (viewOrPrefId == 0) { String fieldName=field.getName(); if (isView) { viewOrPrefId=ResourceUtils.getResourceId(ctx,fieldName); } else { viewOrPrefId=ResourceUtils.getStringId(ctx,fieldName); } } if (viewOrPrefId != 0) { Object val; if (isView) { val=root.findViewById(viewOrPrefId); } else { val=((PreferenceActivity)ctx).findPreference(ctx.getText(viewOrPrefId)); } try { setFieldVal(target,field,val); return true; } catch ( IllegalArgumentException e) { } } return false; }
Example 14
From project Gingerbread-Keyboard, under directory /src/com/android/inputmethod/latin/.
Source file: LatinIME.java

protected void launchSettings(Class<? extends PreferenceActivity> settingsClass){ handleClose(); Intent intent=new Intent(); intent.setClass(LatinIME.this,settingsClass); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); }
Example 15
From project ICS_LatinIME_QHD, under directory /java/src/com/android/inputmethod/latin/.
Source file: LatinIME.java

protected void launchSettingsClass(Class<? extends PreferenceActivity> settingsClass){ handleClose(); Intent intent=new Intent(); intent.setClass(LatinIME.this,settingsClass); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); }
Example 16
From project packages_apps_God_Mode, under directory /src/com/t3hh4xx0r/addons/web/JSON/.
Source file: JSONUtils.java

public PreferenceScreen ParseJSON(PreferenceActivity activity,Context context,boolean refresh){ mContext=context; PreferenceScreen PreferenceRoot=activity.getPreferenceManager().createPreferenceScreen(mContext); InputStream is; if (mJSONParsingInterface != null) { is=mJSONParsingInterface.DownloadJSONScript(refresh); if (is != null) { try { PreferenceRoot=mJSONParsingInterface.ParseJSONScript(PreferenceRoot,is); mJSONParsingInterface.ParsingCompletedSuccess(); } catch ( JSONException e) { e.printStackTrace(); PreferenceRoot=mJSONParsingInterface.unableToParseScript(); } } else { PreferenceRoot=mJSONParsingInterface.unableToDownloadScript(); } } return PreferenceRoot; }
Example 17
From project packages_apps_Phone_1, under directory /src/com/android/phone/.
Source file: CdmaOptions.java

public CdmaOptions(PreferenceActivity prefActivity,PreferenceScreen prefScreen,Phone phone){ mPrefActivity=prefActivity; mPrefScreen=prefScreen; mPhone=phone; create(); }
Example 18
From project platform_packages_apps_phone, under directory /src/com/android/phone/.
Source file: CdmaOptions.java

public CdmaOptions(PreferenceActivity prefActivity,PreferenceScreen prefScreen,Phone phone){ mPrefActivity=prefActivity; mPrefScreen=prefScreen; mPhone=phone; create(); }