I have two apps that work with a same account type. I want below page to be shown when the user opens the second app for first time and one account exists:
But nothing happens when I run this code:
final AccountManagerFuture<Bundle> future = mAccountManager.getAuthToken(account, authTokenType, null, this, null, null);
new Thread(new Runnable() {
@Override
public void run() {
try {
Bundle bnd = future.getResult();
final String authtoken = bnd.getString(AccountManager.KEY_AUTHTOKEN);
showMessage((authtoken != null) ? "SUCCESS!\ntoken: " + authtoken : "FAIL");
Log.d("udinic", "GetToken Bundle is " + bnd);
} catch (Exception e) {
e.printStackTrace();
showMessage(e.getMessage());
}
}
}).start();
The above code works correctly when I run it from the app that has the authenticator. When I run below code instead, system generates a notification that when I click on it, the above picture appears.
final AccountManagerFuture<Bundle> future = mAccountManager
.getAuthToken(account, authTokenType, null, true,
null, handler);
Clicking allow button returns the AuthToken
correctly. However I want to see the grant permission page (above picture) when calling getAuthToken
, not by clicking on notification. How can I do that?