I am showing the AccountPicker dialog from Google Play Services
with this code:
String[] accountTypes = new String[]{"com.google"};
Intent intent = AccountPicker.newChooseAccountIntent(null, null,
accountTypes, false, null, null, null, null);
startActivityForResult(intent, REQUEST_CODE_PICK_ACCOUNT);
It appears as a dark themed dialog even though I am using AppCompat v21 with Theme.AppCompat.Light
.
Is it possible to style the dialog? Preferably as a Material dialog on Lollipop
but at least make it a light dialog to match my app.
I think, no need to "hack". It can be achieved easier:
...
String[] accountTypes = new String[]{GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE};
Intent intent = AccountPicker.newChooseAccountIntent(null, null, accountTypes, false, description, null, null, null);
// set the style
if ( isItDarkTheme ) {
intent.putExtra("overrideTheme", 0);
} else {
intent.putExtra("overrideTheme", 1);
}
intent.putExtra("overrideCustomTheme", 0);
try {
startActivityForResult(intent, YOUR_REQUEST_CODE_PICK_ACCOUNT);
} catch (ActivityNotFoundException e) {
...
}
...
I had the same problem, but I finally found the solution. Take a look to AccountPicker.class, where are methods: newChooseAccountIntent() and zza();
You have to change
AccountPicker.newChooseAccountIntent(null, null,
accountTypes, false, null, null, null, null);
to
AccountPicker.zza(null, null,
accountTypes, false, null, null, null, null, false, 1, 0);
Last two arguments are for "overrideTheme" and "overrideCustomTheme". So set the first one to 1 and it will override the theme to light. :-)
Hope it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With