preferenceactivity

Why does Kit Kat require the use of the isValidFragment?

泄露秘密 提交于 2020-01-01 08:39:47
问题 Ever since KitKat was released, I've noticed a whole bunch of my apps updating with "Fixing a crash in Kit Kat". Recently when I released my own app, I figured out the likely source of that is the new "isValidFragment" requirement for using preference activities. I haven't been able to get anyone, however, to explain why this new class is suddenly needed to validate fragments. Can anyone offer me an explanation of why this is required? 回答1: Subclasses should override this method and verify

Preferences of varying height within a PreferenceActivity

試著忘記壹切 提交于 2019-12-30 18:55:34
问题 I have a custom class that extends Preference that I'm using in conjunction with a PreferenceActivity. When I try to adjust the height in the layout my Preference is using (with a static layout_height or with wrap_content) it is always displayed in a uniform height cell in the Preference Activity - the same size that all of the "normal" preferences default to. Is there a way present a given preference with a different layout_height. I've looked at the API demos related to preferences and I'm

Android Listen For Change in GPS Status?

为君一笑 提交于 2019-12-30 07:46:12
问题 Hello I need to know how to listen for the following with the GPS in Android so I can update the UI in a PreferenceActivity . I have tried GpsStatus.Listener with nothing happening. GpsStatus.GPS_EVENT_STARTED GpsStatus.GPS_EVENT_STOPPED Any suggestions would be great. 回答1: mLocationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); // Define a listener that responds to location updates mGPSStatusListener = new GpsStatus.Listener() { public void onGpsStatusChanged

add action bar with back button in preference activity [duplicate]

為{幸葍}努か 提交于 2019-12-30 06:04:13
问题 This question already has answers here : Creating a Preference Screen with support (v21) Toolbar (13 answers) Closed last year . Here is my preference activity: package com.example.hms.test; import android.os.Bundle; import android.preference.PreferenceActivity; public class PrefsActivity extends PreferenceActivity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.prefs); } } here I want to show an actionbar with name

add action bar with back button in preference activity [duplicate]

微笑、不失礼 提交于 2019-12-30 06:03:37
问题 This question already has answers here : Creating a Preference Screen with support (v21) Toolbar (13 answers) Closed last year . Here is my preference activity: package com.example.hms.test; import android.os.Bundle; import android.preference.PreferenceActivity; public class PrefsActivity extends PreferenceActivity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.prefs); } } here I want to show an actionbar with name

Show up-Button in actionBar in subscreen preferences

淺唱寂寞╮ 提交于 2019-12-30 03:10:09
问题 I've implemented my preferences like shown in the official guidelines. I have a PreferenceActivity which creates the PreferenceFragment like this: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle extras = getIntent().getExtras(); if (extras != null) { Bundle bundle = new Bundle(); _widgetID = extras.getInt(GlobalSettings.EXTRA_WIDGET_ID); bundle.putInt(GlobalSettings.EXTRA_WIDGET_ID, _widgetID); WidgetSettingsFragment fragment = new

SharedPreferences.Editor not being updated after initial commit

大城市里の小女人 提交于 2019-12-25 00:05:38
问题 I'ma a bit confused here. I'm trying to change the value of an EditTextPreference, but it is not updated in the view. (This is in a PreferenceActivity) Here is my code: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.modify_instrument_preferences); // Set default values SharedPreferences customSharedPreference = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences.Editor editor =

Managing SharedPreferences in both PreferenceActivity and Service within same app

六眼飞鱼酱① 提交于 2019-12-24 12:03:11
问题 I'm building an app with a PreferenceActivity and a Service (running in its own remote process due to android:process=":remote" flag) and both need to access programmatically the SharedPreferences . At present time I'm getting a SharedPreference object with the following code that uses the getSharedPreferences method defined in both Service and PreferenceActivity classes: SharedPreferences sharedPrefs = getSharedPreferences("com.mypackage_preferences", MODE_PRIVATE, MODE_MULTI_PROCESS) Is

Android SharedPreferences not changing

好久不见. 提交于 2019-12-24 10:58:20
问题 So I am learning about SharedPreferences within Android. I thought I would quickly try and mock up something simple. When the user selects a particular option from a list of options (3 options in this case) - the layout file will change accordingly. However, it always assumes the default value supplied, hence never changes the layout when another option is selected - so when another option is selected, it is recorded fine, but the layout doesn't change, this leads me to believe that there is

Android - App keeps crashing with error - I think it has to do with Preference Fragments

老子叫甜甜 提交于 2019-12-24 02:58:05
问题 I keep getting an error that has to do with the preferences and I know it has depreciated so I looked here for help http://developer.android.com/reference/android/preference/PreferenceFragment.html and I did exactly as it says on the bottom part... Here is the error: 12-04 00:39:37.553: E/AndroidRuntime(1164): FATAL EXCEPTION: main 12-04 00:39:37.553: E/AndroidRuntime(1164): Process: com.proteintracker, PID: 1164 12-04 00:39:37.553: E/AndroidRuntime(1164): java.lang.RuntimeException: Unable