本文整理汇总了Java中org.holoeverywhere.preference.PreferenceManager.getDefaultSharedPreferences方法的典型用法代码示例。如果您正苦于以下问题:Java PreferenceManager.getDefaultSharedPreferences方法的具体用法?Java PreferenceManager.getDefaultSharedPreferences怎么用?Java PreferenceManager.getDefaultSharedPreferences使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.holoeverywhere.preference.PreferenceManager
的用法示例。
在下文中一共展示了PreferenceManager.getDefaultSharedPreferences方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import org.holoeverywhere.preference.PreferenceManager; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Read in the flag indicating whether or not the user has demonstrated awareness of the
// drawer. See PREF_USER_LEARNED_DRAWER for details.
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity());
mUserLearnedDrawer = sp.getBoolean(PREF_USER_LEARNED_DRAWER, false);
if (savedInstanceState != null) {
mCurrentSelectedPosition = savedInstanceState.getInt(STATE_SELECTED_POSITION);
mFromSavedInstanceState = true;
}
// Select either the default item (0) or the last selected item.
selectItem(mCurrentSelectedPosition);
}
示例2: onCreateView
import org.holoeverywhere.preference.PreferenceManager; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_vertretung, container, false);
appContext = getActivity().getApplicationContext();
startActivity = (StartActivity) getActivity();
// Restore preferences
settings = PreferenceManager.getDefaultSharedPreferences(appContext);
list = (ListView) view.findViewById(R.id.listView1);
klassen = (Spinner) view.findViewById(R.id.spinner1);
txtStand = (TextView) view.findViewById(R.id.txtStand);
pBar = (ProgressBar) view.findViewById(R.id.progressBar1);
listadapter = new VertretungAdapter(startActivity);
list.setAdapter(listadapter);
new LoadClassesTask().execute();
// Inflate the layout for this fragment
return view;
}
示例3: insertDeviceInfo
import org.holoeverywhere.preference.PreferenceManager; //导入方法依赖的package包/类
private void insertDeviceInfo(String deviceInfo, String klasse,
String schoolId, String login, String password, String registration)
throws IOException {
String url = BASE_URL + "register?subId="
+ URLEncoder.encode(registration, "UTF-8") + "&klasse="
+ URLEncoder.encode(klasse, "UTF-8") + "&school="
+ URLEncoder.encode(schoolId, "UTF-8") + "&deviceInfo="
+ URLEncoder.encode(deviceInfo, "UTF-8") + "&login="
+ URLEncoder.encode(login, "UTF-8") + "&password="
+ URLEncoder.encode(password, "UTF-8");
Response response = new Request(url).getResource("UTF-8");
if (response.getResponseCode() == 200) {
Log.d("GCM", "inserted device info");
}
SharedPreferences settings = PreferenceManager
.getDefaultSharedPreferences(this);
settings.edit().putString("regId", registration).commit();
Intent intent = new Intent();
intent.setAction("com.johan.vertretungsplan.registered");
sendBroadcast(intent);
}
示例4: onViewCreated
import org.holoeverywhere.preference.PreferenceManager; //导入方法依赖的package包/类
@Override
public void onViewCreated(final View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
int rot = this.getActivity().getWindowManager().getDefaultDisplay().getRotation();
this.mIsPortraitMode = (rot == Surface.ROTATION_0 || rot == Surface.ROTATION_180);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this.getActivity());
mKeyboardPortraitHeight = prefs.getInt(KEYBOARD_PORTRAIT_HEIGHT_KEY, -1);
mKeyboardLandHeight = prefs.getInt(KEYBOARD_LAND_HEIGHT_KEY, -1);
view.getViewTreeObserver().addOnGlobalLayoutListener(this);
}
示例5: onCreate
import org.holoeverywhere.preference.PreferenceManager; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
Log.w(TAG, "onCreate()");
super.onCreate(savedInstanceState);
context = getSupportActivity();
prefs = PreferenceManager.getDefaultSharedPreferences(context);
editor = prefs.edit();
setRetainInstance(true);
}
示例6: onCreate
import org.holoeverywhere.preference.PreferenceManager; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setHasOptionsMenu(false);
context = getSupportActivity();
prefs = PreferenceManager.getDefaultSharedPreferences(context);
}
示例7: doWakefulWork
import org.holoeverywhere.preference.PreferenceManager; //导入方法依赖的package包/类
@Override
protected void doWakefulWork(Intent intent) {
Log.d(TAG, "doWakefulWork()");
context = getApplicationContext();
prefs = PreferenceManager.getDefaultSharedPreferences(context);
editor = prefs.edit();
long alarmID = intent.getLongExtra(Alarm.PREF_ALARM_ID, -1);
boolean shouldFinish = prefs.getBoolean(PREF_TERMINATE, false);
Log.w(TAG, "Alarm ID retrieved: " + alarmID);
Log.w(TAG, "Should finish: " + shouldFinish);
if(alarmID==-1) {
if(!shouldFinish) {
Log.w(TAG, "Random alarm");
SystemUtils.createScheduleNotification(context, scheduleAlarm());
long end = SystemUtils.createAlarm(context, frequency, -1);
editor.putLong(Alarm.PREF_STATUS_TASKEND, end);
editor.commit();
}
else {
editor.putBoolean(PREF_TERMINATE, false);
editor.commit();
}
}
else {
ScheduleDataSource sDS = new ScheduleDataSource(context);
sDS.open();
Schedule s = sDS.getScheduleByID(alarmID);
SystemUtils.createScheduleNotification(context, s);
s.setIsEnabled(false);
sDS.updateSchedule(context, s);
sDS.close();
}
}
示例8: onResume
import org.holoeverywhere.preference.PreferenceManager; //导入方法依赖的package包/类
@Override
public void onResume() {
super.onResume();
SharedPreferences prefs = PreferenceManager
.getDefaultSharedPreferences(this);
SharedPreferences.Editor prefEditor = prefs.edit();
prefEditor.putBoolean("isInForeground", true);
prefEditor.commit();
}
示例9: onPause
import org.holoeverywhere.preference.PreferenceManager; //导入方法依赖的package包/类
@Override
public void onPause() {
super.onPause();
SharedPreferences prefs = PreferenceManager
.getDefaultSharedPreferences(this);
SharedPreferences.Editor prefEditor = prefs.edit();
prefEditor.putBoolean("isInForeground", false);
prefEditor.commit();
}
示例10: onMessage
import org.holoeverywhere.preference.PreferenceManager; //导入方法依赖的package包/类
/**
* Called when a cloud message has been received.
*/
@Override
public void onMessage(Context context, Intent intent) {
Intent intent2 = new Intent(this, VertretungsplanService.class);
intent2.putExtra(VertretungsplanService.KEY_NOTIFICATION, false);
startService(intent2);
SharedPreferences settings = PreferenceManager
.getDefaultSharedPreferences(context);
if (settings.getBoolean("notification", true)
&& !intent.getStringExtra("message").equals("NO_NOTIFICATION"))
sendNotificationIntent(context, intent.getStringExtra("message"),
true, false);
}
示例11: onPause
import org.holoeverywhere.preference.PreferenceManager; //导入方法依赖的package包/类
@Override
public void onPause() {
super.onPause();
SharedPreferences prefs = PreferenceManager
.getDefaultSharedPreferences(this);
SharedPreferences.Editor prefEditor = prefs.edit();
prefEditor.putBoolean("isInForeground", false);
prefEditor.commit();
AppWidgetManager mgr = AppWidgetManager.getInstance(this);
int[] ids = mgr.getAppWidgetIds(new ComponentName(this,
VertretungsplanWidgetProvider.class));
new VertretungsplanWidgetProvider().onUpdate(this, mgr, ids);
}
示例12: VertretungsplanRemoteViewsFactory
import org.holoeverywhere.preference.PreferenceManager; //导入方法依赖的package包/类
public VertretungsplanRemoteViewsFactory(Context context, Intent intent) {
gson = new Gson();
this.context = context;
appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,
AppWidgetManager.INVALID_APPWIDGET_ID);
prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
}
示例13: show
import org.holoeverywhere.preference.PreferenceManager; //导入方法依赖的package包/类
public void show() {
PackageInfo versionInfo = getPackageInfo();
// the eulaKey changes every time you increment the version number in
// the AndroidManifest.xml
final String eulaKey = EULA_PREFIX + versionInfo.versionCode;
final SharedPreferences prefs = PreferenceManager
.getDefaultSharedPreferences(mActivity);
boolean hasBeenShown = prefs.getBoolean(eulaKey, false);
if (hasBeenShown == false) {
// Show the Eula
String title = mActivity.getString(R.string.app_name) + " v"
+ versionInfo.versionName;
// Includes the updates as well so users know what changed.
String message = mActivity.getString(R.string.updates) + "\n\n"
+ mActivity.getString(R.string.disclaimer);
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity)
.setTitle(title)
.setMessage(message)
.setPositiveButton(android.R.string.ok,
new Dialog.OnClickListener() {
@Override
public void onClick(
DialogInterface dialogInterface, int i) {
// Mark this version as read.
SharedPreferences.Editor editor = prefs
.edit();
editor.putBoolean(eulaKey, true);
editor.commit();
dialogInterface.dismiss();
}
})
.setNegativeButton(android.R.string.cancel,
new Dialog.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
// Close the activity as they have declined
// the EULA
mActivity.finish();
}
});
builder.create().show();
}
}
示例14: getSharedPreferences
import org.holoeverywhere.preference.PreferenceManager; //导入方法依赖的package包/类
public SharedPreferences getSharedPreferences() {
return PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
}
示例15: setUp
import org.holoeverywhere.preference.PreferenceManager; //导入方法依赖的package包/类
/**
* Users of this fragment must call this method to set up the navigation drawer interactions.
*
* @param fragmentId The android:id of this fragment in its activity's layout.
* @param drawerLayout The DrawerLayout containing this fragment's UI.
*/
public void setUp(int fragmentId, DrawerLayout drawerLayout) {
mFragmentContainerView = getActivity().findViewById(fragmentId);
mDrawerLayout = drawerLayout;
// set a custom shadow that overlays the main content when the drawer opens
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
// set up the drawer's list view with items and click listener
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeButtonEnabled(true);
// ActionBarDrawerToggle ties together the the proper interactions
// between the navigation drawer and the action bar app icon.
mDrawerToggle = new ActionBarDrawerToggle(
getActivity(), /* host Activity */
mDrawerLayout, /* DrawerLayout object */
R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */
R.string.navigation_drawer_open, /* "open drawer" description for accessibility */
R.string.navigation_drawer_close /* "close drawer" description for accessibility */
) {
@Override
public void onDrawerClosed(View drawerView) {
super.onDrawerClosed(drawerView);
if (!isAdded()) {
return;
}
getActivity().supportInvalidateOptionsMenu(); // calls onPrepareOptionsMenu()
}
@Override
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
if (!isAdded()) {
return;
}
if (!mUserLearnedDrawer) {
// The user manually opened the drawer; store this flag to prevent auto-showing
// the navigation drawer automatically in the future.
mUserLearnedDrawer = true;
SharedPreferences sp = PreferenceManager
.getDefaultSharedPreferences(getActivity());
sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).apply();
}
getActivity().supportInvalidateOptionsMenu(); // calls onPrepareOptionsMenu()
}
};
// If the user hasn't 'learned' about the drawer, open it to introduce them to the drawer,
// per the navigation drawer design guidelines.
if (!mUserLearnedDrawer && !mFromSavedInstanceState) {
mDrawerLayout.openDrawer(mFragmentContainerView);
}
// Defer code dependent on restoration of previous instance state.
mDrawerLayout.post(new Runnable() {
@Override
public void run() {
mDrawerToggle.syncState();
}
});
mDrawerLayout.setDrawerListener(mDrawerToggle);
}