Android 8.0 Oreo - Accounts

android 8.0 oreo download
download android 8.0 oreo apk
android 8.1 download
android 8.0 download zip file
android 10
android 9
android 7
android.com/beta oreo

In my app, I need to known if there is any Google account or any Samsung account.

Up to Android 7 it was easy to get this information with something like:

    Account[] accounts = AccountManager.get(getContext())
.getAccountsByType("com.google")

But with the event of Oreo this does not work anymore.

EDIT: see official information on this subject: In Android 8.0 (API level 26), apps can no longer get access to user accounts unless the authenticator owns the accounts or the user grants that access. The GET_ACCOUNTS permission is no longer sufficient. To be granted access to an account, apps should either use AccountManager.newChooseAccountIntent() or an authenticator-specific method. After getting access to accounts, an app can can call AccountManager.getAccounts() to access them. Android 8.0 deprecates LOGIN_ACCOUNTS_CHANGED_ACTION. Apps should instead use addOnAccountsUpdatedListener() to get updates about accounts during runtime. For information about new APIs and methods added for account access and discoverability, see Account Access and Discoverability in the New APIs section of this document

I spent half a day to find a solution to my need, without success.

I've found information claiming that now the only way to access to accounts is to use AccountPicker like this:

AccountPicker.newChooseAccountIntent(null, null, new String[]{"com.google"},true, null, null, null, null);

But this does respond to my problem. To be clear I only need to know if an account exists for a certain type (Google, Samsung...) I do not need to know how much if so and do not need accounts information.

Using "android.permission.READ_CONTACTS" permission, and

    Account[] accounts = AccountManager.get(getContext())
.getAccountsByType("com.google") 

working again in android Oreo

Android 8.0 Behavior Changes, API behavior changes that can affect apps running on Android 8.0 Oreo. changes that you should understand and account for in your apps. Step 1: Scroll down notification bar from any screen on Oreo. Step 2: Tap user icon in quick settings menu. Step 3: Tap add user. Step 4: Tap OK. Step 5: Tap continue to set up new user on android 8.0 Oreo. Step 6: Enter name want to create new user account & tap Next. Step 7: Tap Agree. Step

As you already said, there's no way to read other accounts if the user didn't give you the permission to do so. The permission now is provided not only with the run-time permission but even with the account picker, i.e. an account is visible to your app only if the user selected the account after you called the account picker. This new restriction is exactly to avoid what you are trying to do: read all user accounts. There's no solution to your problem, the only thing you can do is to present the picker to the user and let him select all the accounts, not the best user experience however.

Edit: starting from Google Play Services 11.6 there's now a new method requestGoogleAccountsAccess() to get all Google accounts.

Android 8.0 Features and APIs, Highlights of what's new for developers in Android 8.0 Oreo. Users can long-​press on app launcher icons to view notifications in Android 8.0. The GET_ACCOUNTS permission is no longer sufficient. To be granted access to an account, apps should either use AccountManager.newChooseAccountIntent() or an authenticator-specific method. After getting access to accounts, an app can can call AccountManager.getAccounts() to access them. Android 8.0 deprecates LOGIN_ACCOUNTS_CHANGED_ACTION.

To get the installed google accounts on a device running Oreo+ (8+) with this code

 Account[] accounts = AccountManager.get(getContext()).getAccountsByType("com.google")

You need to first call

https://developers.google.com/android/reference/com/google/android/gms/auth/GoogleAuthUtil.html#requestGoogleAccountsAccess(android.content.Context)

Please add the following dependency first

com.google.android.gms:play-services-auth:16.0.0

The call requestGoogleAccountsAccess() throws an exception which you can cast (after checking) to UserRecoverableAuthException and get an intent from it to start with startActivityForResult

Here is some example code, working on Android Oreo

// call this on a background thread!
private void requestGoogleAccountAccess() throws Exception
{
    googleAccountAccessGranted = GoogleAuthUtil.requestGoogleAccountsAccess(this);
    Log.i(TAG, "googleAccountAccessGranted: " + googleAccountAccessGranted);
}

// exception handler after calling method above
private void handleAuthResult(Throwable e)
{
    if (e instanceof UserRecoverableAuthException)
    {
        UserRecoverableAuthException authException = (UserRecoverableAuthException) e;
        startActivityForResult(authException.getIntent(), AUTH_PERMISSION_REQUEST);
    }
    else
    {
        Log.e(TAG, "Cannot request Google Account Access", e);
    }
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == AUTH_PERMISSION_REQUEST)
    {
        Log.i(TAG, "Google Auth Permission Result");

        if (resultCode == Activity.RESULT_CANCELED)
        {
            Log.w(TAG, "User Cancelled Play Services Auth Request.")
        }
        else if (resultCode == Activity.RESULT_OK)
        {
            Log.d(TAG, "User accepted Play Services Auth Request.");
            // call the following line again on a background thread. the call now returns a boolean instead of throwing an exception
            //  googleAccountAccessGranted = GoogleAuthUtil.requestGoogleAccountsAccess(this);
        }
    }
}

It's a bit strange why Google decided themselves for this "architecture". Why not return a Task, etc. But this is how you get it working.

Of course this code needs proper exception handling which I left out for readability.

Android 8.0 Oreo - Accounts, With its latest Android version, Google aims to make the mobile OS more worry, it's time to prepare your phone for the crunchy and creamy Android 8.0 Oreo. By Google's own accounting, just 13.5 percent of users are using Android 7.0 or  Android Oreo helps minimize background activity in the apps you use least, it's the super power you can't even see. A hero who’s ready before you are. With your permission, Autofill remembers your logins to get you into your favorite apps at supersonic speed. Smart text selection: Android Oreo recognizes text when you tap or select, then

Google Android 8.0 Oreo Review, As of March 2020, 20.09% of Android devices run Oreo, with 7.94% on Android 8.0 (API 26) and 12.15% using Android 8.1 (API 27), meaning 8.1 is behind Android 10, by now the second most popular single version while both Oreo versions combined are still more popular. Android 8.0 Oreo introduced Notification Channels, or custom app-defined categories for notifications. The YouTube app is a good example: It splits notifications into two groups, offline

Android Oreo, Everything you need to know about Android 8.0 Oreo. Android 8.1 update allows users to see speed of public Wi-Fi networks. By Christian de Looper January 23,​  Google Account Manager Oreo 8.0, 8.1.0 FRP Bypass APK App Download. Search engines account supervisor Oreo 8. 0, 8. 1. 0, 8. 1 two, search engines account supervisor Oreo 8. 0, Search engines account supervisor for google android 8. 0, google accounts manager most recent apk Apps download is here now.

Android 8.0 Oreo: Every New Feature, Release Date, and More, Samsung Galaxy S8 Active. March 29, 2018 – T-Mobile US: T-Mobile users can update to Oreo by Duration: 10:09 Posted: 4 days ago Follow the steps below to set up email on your Android device. 1. Tap the Settings icon. 2. Tap Cloud and accounts. 3. From the Cloud and accounts panel, tap Accounts. 4. From the Accounts panel, tap Add account.

Comments
  • what do you mean by "this does not work anymore" ? can you provide some code, log or stack trace, whatever seems relevant to you, in order for the community to be able to help you ?
  • I mean the getAccount() method do not return account data anymore execept if for accounts which are linked to the App.
  • Here is more details from official documentation: In Android 8.0 (API level 26), apps can no longer get access to user accounts unless the authenticator owns the accounts or the user grants that access.
  • @Steeve Favre can u share the link regarding that and will u please tell how can this be resolved.
  • Please see my answer. This is how you get it working
  • As I said, I do NOT want to read any information about accounts. I just need to know if one exists for a certain type that's all. But I guess that you are right that even for that there is no solution.
  • I know this is late, so I'll post only for future readers. Learning about whether or not an account exists is still information you need access to obtain. IE: the user may not want you to know what accounts exist as the existence of an account is in itself private information.
  • @AaronTHarris will u please tell how this problem get resolved how can I get the name of user from linked google Account.
  • Please see my answer. This is how you get it working