I upgraded my app from API 28 to 29. Tested its debug and release version. Everything works fine. However after publishing in the play store, the apps behaves weirdly.
Problem: It seems the default values for shared preferences are not correct.
I can't find any notes inside googles developer information for android 10.
Code:
Inside Activity
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
String birthdaysKey = "app.birthdays";
birthdays = prefs.getBoolean(birthdaysKey, false);
Inside XML
<SwitchPreferenceCompat
android:defaultValue="false"
app:icon="@drawable/ic_birthday_24dp"
app:key="app.birthdays"
app:summary="@string/birthday_description"
app:title="@string/birthday"
app:useSimpleSummaryProvider="false" />
buildgradle
implementation 'androidx.preference:preference:1.1.1'
The initial value is always true, but should be false.
I managed to find the following information:
<androidx.preference.PreferenceScreen ... and <androidx.preference.SwitchPreference ...
The problem I am facing is: How to use a preference screen without the default preference manager? There is no other way to read the data afaik.
Solution:
Disable AutoUpdate inside the manifest. This fixes the issue.