Changing the Google Play Services Plugin Dialog Style

I am showing an 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 displays as a dark theme dialogue, although I am using AppCompat v21 with Theme.AppCompat.Light.

Can I customize the dialog? Preferably, like the Material dialog on Lollipop, but at least make it an easy dialog to fit my application.

+4
source share
2 answers

I think there is no need to "hack". It could be simpler:

  ... 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) { ... } ... 
+8
source

I had the same problem, but I finally found a solution. Take a look at AccountPicker.class, where the methods are: 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); 

The last two arguments are for "overrideTheme" and "overrideCustomTheme". So set the first to 1 and it will redefine the theme for coverage. :-)

Hope this helps.

+2
source

All Articles