Created
May 23, 2019 16:29
-
-
Save reuniware/6e95ae8a0873271f5d514671251cd173 to your computer and use it in GitHub Desktop.
Android Kotlin AccountManager remove accounts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val accountManager = this.applicationContext.getSystemService(Context.ACCOUNT_SERVICE) as AccountManager | |
val account = Account("syncaccount", "com.datasync.syncserviceaccount") | |
val accounts = accountManager.accounts | |
accounts.forEach { | |
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1) { | |
accountManager.removeAccount(account, null, null) | |
} else { | |
accountManager.removeAccountExplicitly(account) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment