How do I get accounts on Android Oreo? I went through "Account access and discoverability" in documentation:
https://developer.android.com/about/versions/oreo/android-8.0-changes.html
but it is a ZERO help, and there are also no examples or at least something i can start with...
I always use this approach (after granted permission GET_ACCOUNTS from user):
val mUserList = arrayListOf<String>()
val accountManager = getSystemService(Context.ACCOUNT_SERVICE) as AccountManager
val accounts = accountManager.accounts
accounts
.filter {
!mUserList.contains(it.name) &&
it.name.contains("google.com") ||
it.name.contains("example.domain")
}.map { mUserList.add(it.name) }
This is working on any API except 26 and 27.
So I'm traversing trough all the accounts (accountManager.accounts) and filtering only the domains I need and put them in a list, then I send that list to a custom dialog where user can pick which one he wants, and that leads him to a password dialog, plain and simple.
How do I do that for Oreo, and will it be backward compatible?