I've created my custom authenticator for my app. I'm now up to a point where I want to allow the user to remove their account if they'd like to do so. I know that I define a settings screen for my authenticator within my authenticator XML file:
<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
android:accountType="@string/authentication_account_type"
android:icon="@drawable/ic_launcher"
android:smallIcon="@drawable/ic_launcher"
android:label="@string/app_name"
android:accountPreferences="@xml/authenticator_preferences" />
The last attribute, android:accountPreferences
, is where I define a PreferenceScreen
XML. This is where I'm having trouble... From my understanding, the preferences that I define in android:accountPreferences
is what is shown when the end user clicks on their account under the device settings. However, how do I read from these preferences? Or handle click events for each preference? All that I'm hoping to do is allow the user to remove their account, directly from the preferences screen that's provided by the OS.
I've looked at other potential solutions already on SO:
Android: read preferences set in authenticator xml
Android account authenticator: distinguish between accounts in preference screen
Can't access preferences set in account-authenticator in Android
However, the best answer I can find from these previous questions is to include an <intent>
tag within the <PreferenceScreen>
and launch a settings activity that you define. However, that doesn't make sense to me... I looked at my personal phone and each account that I have displays a preferences screen that appears native to the OS. Shouldn't I be able to define my preferences in the same way? I've looked at both a Samsung Galaxy S9 and a Pixel 3 and the settings screens on both appear native.
How can I achieve the same effect? More importantly, how can I interact with these settings? As always, any assistance on this would be greatly appreciated!