PreferenceActivity Crashes in Android 4.4 (KitKat)

Are you using a custom PreferenceActivity in your Android application?  Well then you better push a quick update because chances are your application will crash on Android 4.4.

Why?  There was a new method 'protected boolean isValidFragment (String fragmentName)added to the PreferenceActivity in API 19.  The purpose of this protected method is probably to prevent issues with Fragment Injection. The default implementation of isValidFragment will throw an exception for KitKat and above.

How can you fix it?  Simply add an implementation for 'isValidFragment' to your class that derives from PreferenceActivity (example below).  And let the app updates begin!

protected boolean isValidFragment (String fragmentName)
{
    if(MyPreferencesFragment.class.getName().equals(fragmentName)){
        return true;
    }
    return false;
}

 

Thank you for your interest!

We will contact you as soon as possible.

Send us a message

Oops, something went wrong
Please try again or contact us by email at info@tikalk.com