本文整理汇总了Java中org.holoeverywhere.preference.PreferenceManager类的典型用法代码示例。如果您正苦于以下问题:Java PreferenceManager类的具体用法?Java PreferenceManager怎么用?Java PreferenceManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PreferenceManager类属于org.holoeverywhere.preference包,在下文中一共展示了PreferenceManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:wuyingren,项目名称:WhatsAnnoyProject,代码行数:18,代码来源:NavigationDrawerFragment.java
示例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;
}
开发者ID:johan12345,项目名称:ls-vertretungsplan,代码行数:23,代码来源:VertretungFragment.java
示例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);
}
开发者ID:johan12345,项目名称:ls-vertretungsplan,代码行数:23,代码来源:GCMIntentService.java
示例4: onClick
import org.holoeverywhere.preference.PreferenceManager; //导入依赖的package包/类
@SuppressLint("NewApi")
@Override
public void onClick(View v) {
if (mDoNotShowCheckBox.isChecked()) {
SharedPreferences.Editor prefsEditor = PreferenceManager.getDefaultSharedPreferences(SDWarningDialog.this).edit();
prefsEditor.putBoolean(SettingsAccessor.SHOW_SD_WARNING_KEY, false);
if (Build.VERSION.SDK_INT >= 9) {
prefsEditor.apply();
} else {
prefsEditor.commit();
}
}
SDWarningDialog.this.finish();
}
开发者ID:saltisgood,项目名称:opensnap,代码行数:15,代码来源:SDWarningDialog.java
示例5: 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);
}
开发者ID:saltisgood,项目名称:opensnap,代码行数:14,代码来源:SnapEditorBaseFrag.java
示例6: 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);
}
开发者ID:wuyingren,项目名称:WhatsAnnoyProject,代码行数:10,代码来源:RandomFragment.java
示例7: onCreate
import org.holoeverywhere.preference.PreferenceManager; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setHasOptionsMenu(false);
context = getSupportActivity();
prefs = PreferenceManager.getDefaultSharedPreferences(context);
}
开发者ID:wuyingren,项目名称:WhatsAnnoyProject,代码行数:8,代码来源:NowFragment.java
示例8: 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();
}
}
开发者ID:wuyingren,项目名称:WhatsAnnoyProject,代码行数:40,代码来源:RandomNotificationService.java
示例9: 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();
}
开发者ID:johan12345,项目名称:ls-vertretungsplan,代码行数:10,代码来源:StartActivity.java
示例10: 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();
}
开发者ID:johan12345,项目名称:ls-vertretungsplan,代码行数:10,代码来源:StartActivity.java
示例11: 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);
}
开发者ID:johan12345,项目名称:ls-vertretungsplan,代码行数:17,代码来源:GCMIntentService.java
示例12: 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);
}
开发者ID:johan12345,项目名称:ls-vertretungsplan,代码行数:15,代码来源:SettingsActivity.java
示例13: 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());
}
开发者ID:johan12345,项目名称:ls-vertretungsplan,代码行数:8,代码来源:VertretungsplanWidgetService.java
示例14: 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();
}
}
开发者ID:ericcurtin,项目名称:Fall-Monitor,代码行数:52,代码来源:Eula.java
示例15: getSharedPreferences
import org.holoeverywhere.preference.PreferenceManager; //导入依赖的package包/类
public SharedPreferences getSharedPreferences() {
return PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
}
开发者ID:restorer,项目名称:gloomy-dungeons-2,代码行数:4,代码来源:MyApplication.java
示例16: 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);
}
开发者ID:wuyingren,项目名称:WhatsAnnoyProject,代码行数:74,代码来源:NavigationDrawerFragment.java
示例17: onCreate
import org.holoeverywhere.preference.PreferenceManager; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
appContext = getApplicationContext();
settings = PreferenceManager
.getDefaultSharedPreferences(getApplicationContext());
if (!settings.contains("selected_school")) {
settings.edit().putString("selected_school", "Schleswig_Lornsenschule").commit();
}
vertretungFragment = new VertretungFragment();
nachrichtenFragment = new NachrichtenFragment();
addTab("Vertretungsplan", vertretungFragment);
addTab("Nachrichten", nachrichtenFragment);
tabs = (PagerSlidingTabStrip) findViewById(R.id.tabs);
tabs.setViewPager(mViewPager);
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
getResources().getConfiguration();
if (metrics.widthPixels / (metrics.densityDpi / 160f) >= 800
&& getResources().getConfiguration().orientation == android.content.res.Configuration.ORIENTATION_LANDSCAPE) {
tabs.setVisibility(View.GONE);
}
tabs.setOnPageChangeListener(adapter);
tabs.setIndicatorColor(Color.rgb(51, 139, 255));
// Launch license dialog
showDialogs();
if (savedInstanceState == null) {
if (settings.getString("regId", null) != null)
new GetVertretungsplanTask().execute();
else {
setProgress(true);
// wait for GCM registration
registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
unregisterReceiver(this);
new GetVertretungsplanTask().execute();
}
}, new IntentFilter("com.johan.vertretungsplan.registered"));
}
} else {
Log.d("vertretungsplan", "load");
vertretungsplan = new Gson().fromJson(
savedInstanceState.getString("vertretungsplan"),
Vertretungsplan.class);
}
}
开发者ID:johan12345,项目名称:ls-vertretungsplan,代码行数:55,代码来源:StartActivity.java
示例18: onRegistered
import org.holoeverywhere.preference.PreferenceManager; //导入依赖的package包/类
/**
* Called back when a registration token has been received from the Google
* Cloud Messaging service.
*
* @param context
* the Context
*/
@Override
public void onRegistered(Context context, String registration) {
boolean alreadyRegisteredWithEndpointServer = false;
try {
SharedPreferences settings = PreferenceManager
.getDefaultSharedPreferences(context);
String deviceInfo = URLEncoder.encode(android.os.Build.MANUFACTURER
+ " " + android.os.Build.PRODUCT, "UTF-8");
String klasse = settings.getString("klasse", "");
String schoolId = settings.getString("selected_school", "");
String login = settings.getString("login", "");
String password = settings.getString("password", "");
/*
* Using cloud endpoints, see if the device has already been
* registered with the backend
*/
DeviceInfo existingInfo = getDeviceInfo(registration);
if (existingInfo != null && registration.equals(existingInfo.subId)
&& klasse.equals(existingInfo.klasse)
&& schoolId.equals(existingInfo.schoolId)) {
alreadyRegisteredWithEndpointServer = true;
}
if (!alreadyRegisteredWithEndpointServer) {
/*
* We are not registered as yet. Send an endpoint message
* containing the GCM registration id and some of the device's
* product information over to the backend. Then, we'll be
* registered.
*/
insertDeviceInfo(deviceInfo, klasse, schoolId, login, password,
registration);
}
} catch (IOException | JSONException e) {
Log.e(GCMIntentService.class.getName(),
"Exception received when attempting to register with server",
e);
Log.d("Vertretungsplan",
"1) Registration with Google Cloud Messaging...SUCCEEDED!\n\n"
+ "2) Registration with Endpoints Server...FAILED!\n\n"
+ "Unable to register your device with your Cloud Endpoints server. "
+ "Either your Cloud Endpoints server is not deployed to App Engine, or "
+ "your settings need to be changed to run against a local instance "
+ "by setting LOCAL_ANDROID_RUN to 'true' in CloudEndpointUtils.java.");
return;
}
}
开发者ID:johan12345,项目名称:ls-vertretungsplan,代码行数:61,代码来源:GCMIntentService.java
示例19: sendNotificationIntent
import org.holoeverywhere.preference.PreferenceManager; //导入依赖的package包/类
/**
* Generate a notification intent and dispatch it to the RegisterActivity.
* This is how we get information from this service (non-UI) back to the
* activity.
*
* For this to work, the 'android:launchMode="singleTop"' attribute needs to
* be set for the RegisterActivity in AndroidManifest.xml.
*
* @param context
* the application context
* @param message
* the message to send
* @param isError
* true if the message is an error-related message; false
* otherwise
* @param isRegistrationMessage
* true if this message is related to registration/unregistration
*/
private void sendNotificationIntent(Context context, String message,
boolean isError, boolean isRegistrationMessage) {
// App wird nicht angezeigt
SharedPreferences settings = PreferenceManager
.getDefaultSharedPreferences(context);
String sound = settings.getString("ringtone", RingtoneManager
.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION).toString());
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
context).setSmallIcon(R.drawable.ic_notification)
.setContentTitle("Nachricht");
mBuilder.setContentText("Es gibt neue Änderungen auf dem Vertretungsplan");
if (!sound.equals("")) {
Uri soundUri = Uri.parse(sound);
mBuilder.setSound(soundUri);
}
mBuilder.setDefaults(Notification.DEFAULT_VIBRATE
| Notification.DEFAULT_LIGHTS);
mBuilder.setOnlyAlertOnce(true);
mBuilder.setAutoCancel(true);
// Creates an explicit intent for an Activity in your app
Intent resultIntent = new Intent(context, StartActivity.class);
// The stack builder object will contain an artificial back stack for
// the
// started Activity.
// This ensures that navigating backward from the Activity leads out of
// your application to the Home screen.
TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
// Adds the back stack for the Intent (but not the Intent itself)
stackBuilder.addParentStack(StartActivity.class);
// Adds the Intent that starts the Activity to the top of the stack
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0,
PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder.setContentIntent(resultPendingIntent);
NotificationManager mNotificationManager = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
// mId allows you to update the notification later on.
int mId = 1;
mNotificationManager.notify(mId, mBuilder.build());
}
开发者ID:johan12345,项目名称:ls-vertretungsplan,代码行数:61,代码来源:GCMIntentService.java
示例20: getSharedPreferences
import org.holoeverywhere.preference.PreferenceManager; //导入依赖的package包/类
private SharedPreferences getSharedPreferences() {
return PreferenceManager.getDefaultSharedPreferences(TflApplication.getLastInstance());
}
开发者ID:antonyt,项目名称:TflTravelAlerts,代码行数:4,代码来源:SharedPreferencesStore.java
注:本文中的org.holoeverywhere.preference.PreferenceManager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论