AccountManager
The AccountManager
class provides access to all the registered users' online accounts. This way, the user only needs to provide his/her credentials once for each account and then he/she can grant access to these applications in a simpler way. Using the AccountManager
class, you can get a token that can be used as a form of authentication in different services.
The steps that you need to take in order to make use of this feature are as follows:
First, you need to modify the
manifest
file and add permission to use credentials:<uses-permission android:name="android.permission.USE_CREDENTIALS"> </uses-permission>
Once your application can use credentials, you can get an instance of
AccountManager
using theget(Context c)
method:AccountManager am = AccountManager.get(this);
Now, you have an instance of
AccountManager
, but you need to know which accounts are available. To do this, you can use thegetAccountsByType(String s)
method. TheString
parameter is the name of...