I have done this following this answer:
What features are supported by Android's Google accounts authenticator?
Don't know how up to date are the codes, but the ones you need are working.
private static final String ACCOUNT_TYPE_GOOGLE = "com.google";
private static final String[] FEATURES = { "service_mail","service_cl","service_sitemaps" };
private void testGetAccountsByTypeAndFeatures() {
AccountManagerFuture<Account[]> accounts = AccountManager.get(this).getAccountsByTypeAndFeatures(ACCOUNT_TYPE_GOOGLE, FEATURES, new AccountManagerCallback<Account[]>() {
@Override
public void run(AccountManagerFuture<Account[]> future) {
try {
for (Account account : future.getResult()) {
Log.d("ACCOUNT",account.toString());
}
} catch (OperationCanceledException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (AuthenticatorException e) {
e.printStackTrace();
}
}
}, null);
}
Don't forget to add the permission
<uses-permission android:name="android.permission.GET_ACCOUNTS" />