Back to project page sharemore.
The source code is released under:
GNU General Public License
If you think the Android project sharemore listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/******************************************************************************* * Copyright (c) 2012 Moarub Oy./*w w w. j a v a 2 s . co m*/ * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Public License v3.0 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/gpl.html * * Contributors: * Moarub Oy - initial API and implementation ******************************************************************************/ package com.moarub.sharemore; import com.moarub.sharemore.R; import android.content.SharedPreferences; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.os.Bundle; import android.preference.Preference; import android.preference.PreferenceFragment; public class ShareMorePreferenceFragment extends PreferenceFragment implements OnSharedPreferenceChangeListener { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); } @Override public void onResume() { super.onResume(); getPreferenceScreen().getSharedPreferences() .registerOnSharedPreferenceChangeListener(this); Preference pref = findPreference("kippt_username"); SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences(); pref.setSummary(sharedPreferences.getString("kippt_username", "")); Preference pw = findPreference("kippt_token"); pw.setSummary(sharedPreferences.getString("kippt_token", "")); } @Override public void onPause() { super.onPause(); getPreferenceScreen().getSharedPreferences() .unregisterOnSharedPreferenceChangeListener(this); } @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { if (key == null) { return; } if (key.equalsIgnoreCase("kippt_username")) { Preference pref = findPreference(key); pref.setSummary(sharedPreferences.getString(key, "")); } else if (key.equalsIgnoreCase("kippt_token")) { Preference pw = findPreference(key); pw.setSummary(sharedPreferences.getString(key, "")); } } }