Get Registered Email Accounts - Androhub

Registered Accounts Banner

Get Registered Email Accounts

Today we are going to learn how to fetch all registered email accounts from our device like google, facebook, etc. For fetching email accounts details we are going to use AccountManager.

AccountManager class provides access to a centralised registry of the user’s online accounts. The user enters credentials (username and password) once per account, granting applications access to online resources with “one-click” approval.

Example

1. Create a new project in Android Studio by navigating to File ⇒ New ⇒ New Project and fill required details. By default my activity is MainActivity.java.

2. First create a xml layout naming activity_main.xml and add the following code. In this layout we are going to display registered email accounts on TextView.

3. Now come to your MainActivity.java and add the following code. In this code first we are fetching google accounts and all registered accounts as well. By using AccountManager we can fetch account type so by fetching account type we can fetch account details related to that particular account like we fetched google account details by using com.google account type.

4. Now, you are all done, you can use above code to fetch account details according to your requirements.

Thanks. :)

 

Post comment

Your email address will not be published. Required fields are marked *