Back to project page surveygcp.
The source code is released under:
GNU General Public License
If you think the Android project surveygcp listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package org.droidplanner.gcp.activitys; //from w ww . ja v a 2 s . com import org.droidplanner.gcp.R; import android.content.SharedPreferences; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.content.pm.PackageManager.NameNotFoundException; import android.os.Bundle; import android.preference.EditTextPreference; import android.preference.PreferenceActivity; import android.preference.PreferenceManager; public class SettingsActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener { @SuppressWarnings("deprecation") // TODO use more up-to-date code @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); SharedPreferences sharedPref = PreferenceManager .getDefaultSharedPreferences(this); findPreference("pref_map_type").setSummary( sharedPref.getString("pref_map_type", "")); try { EditTextPreference versionPref = (EditTextPreference) findPreference("pref_version"); String version = getPackageManager().getPackageInfo( getPackageName(), 0).versionName; versionPref.setSummary(version); } catch (NameNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } } @SuppressWarnings("deprecation") public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { if (key.equals("pref_map_type")) { findPreference(key) .setSummary(sharedPreferences.getString(key, "")); } } @SuppressWarnings("deprecation") @Override protected void onResume() { super.onResume(); getPreferenceScreen().getSharedPreferences() .registerOnSharedPreferenceChangeListener(this); } @SuppressWarnings("deprecation") @Override protected void onPause() { super.onPause(); getPreferenceScreen().getSharedPreferences() .unregisterOnSharedPreferenceChangeListener(this); } }