Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to get all accoutns registered in device ?

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 182
    Comment on it

    Sometimes it is required to get all the accounts registered in device like facebook , gmail, linkedin account as well as whatsapp account.

    Account Manager provides list of all centralized account of device.

    First of all we can have the instance of account manager using get(Context) method.

    then we can List the available accounts using getAccountType(String type) if anyone interested in account type otherwise use getAccounts().

    AccountManager accoutnManager = AccountManager.get(this);
    
    Account [] accounts = accoutnManager.getAccounts();
    if (accounts.length > 0){
    
            String totals = "";
            for (int i=0; i<accounts.length; i++){
    
            totals += accounts[i] + "\n";
    
            }
    
            accounts.setText(totals)

    getAccounts() return the list of accounts, it's safe to call this from Main thread.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: