I am struggling to understand the Android Account Manager API. As far as I was thinking of working, I can use the blockingGetAuthToken method and specify whether Android should provide a notification to allow or deny the request for the user. Another possibility is use getAuthToken and check whether the KEY_INTENT is back. If so, then I can start a new activity where the user can confirm my request.
My problem is that I would like to call one of these two methods from within the service.
Thank you for your help
You want a callback after the user has a It is probably better to use the Asynchronous version of the decision:
Account Manager MGR = AccountManager.get (getApplicationContext ()); Account [] accounts = mfgetexnettype ("comm. Ma'emmen"); // Loud accounts are not empty
You would like to use an AccountManagerFuture & lt;
to hold the results of the authentication token; Bundle & gt; This should be ASC, because the Android device can ask the user to login in the meantime:
Private Account Manager Future & lt; Bundle & gt; MyFuture = null; Private account manager callbacks & lt; Bundle & gt; MyCallback = New AccountManagerCallback & LT; Bundle & gt; () {@Override Public Zero Run (Last AccountManagerFuture & lt; bundle> Arg0). {Try {myFuture.getResult () find (AccountManager.KEY_AUTHTOKEN); // This is your auth token) hold (exception e) {// handle error}}
}
Now you can ask ayntone token asynchronous:
myFuture = mgr.getAuthToken (accounts [0], AUTH_TOKEN_TYPE, true, myCallback, null);
Comments
Post a Comment