Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Below steps are require to login to Google.</p> <p><strong>1-</strong> Select an account from your device using below code</p> <pre><code>public static AccountManager accountManager; accountManager = AccountManager.get(this); Account[] accounts = accountManager.getAccountsByType("com.google"); </code></pre> <p><strong>2-</strong> Get a Token from selected account using below code</p> <pre><code>private void onAccountSelected(final Account account) { accountManager.getAuthToken(account, AUTH_TOKEN_TYPE, null, this, new AccountManagerCallback&lt;Bundle&gt;() { public void run(AccountManagerFuture&lt;Bundle&gt; future) { try { String token = future.getResult().getString(AccountManager.KEY_AUTHTOKEN); useToken(account, token); } catch (OperationCanceledException e) { onAccessDenied(); } catch (Exception e) { handleException(e); } } }, null); } </code></pre> <p><strong>3-</strong> now Authenticate the Token using user account and Token. you will be able to login to google.</p> <p><em><strong>NOTE:</em></strong> you will get Authentication full code from here <a href="http://code.google.com/p/google-mail-oauth2-tools/wiki/JavaSampleCode" rel="nofollow">Authentication code</a> , put your gmail a/c and token where required. now you are able to loging using OAuth.</p> <p><strong>4-</strong> for re login you have to invalidate your token using below code</p> <pre><code>accountManager.invalidateAuthToken("com.google", token); </code></pre> <p><strong>5-</strong> after invalidate you have to get a new token using below code</p> <pre><code> String newToken = AccountManager.get(this).getAuthToken(new Account(account, "com.google"), AUTH_TOKEN_TYPE, true, null, null).getResult().getString(AccountManager.KEY_AUTHTOKEN); </code></pre> <p><strong>6-</strong> in your AndroidManifest.xml add below uses permissions</p> <pre><code>&lt;uses-permission android:name="android.permission.INTERNET"/&gt; &lt;uses-permission android:name="android.permission.GET_ACCOUNTS"/&gt; &lt;uses-permission android:name="android.permission.USE_CREDENTIALS"/&gt; </code></pre> <p>Thats all you require, now enjoy.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload