Google Account Authenticator asks for permission at run-time

女生的网名这么多〃 提交于 2019-12-06 08:19:22

问题


I use AccountManager.getAuthToken from my service to have access to Googledocs and Spreadsheet API.

As I'm doing it from background and don't want to interrupt user , I allow accountManager to raise notification when user interaction needed (using parameter boolean notifyAuthFailure).

As I expected, CallBack is called with AccounManagerFuture,which resolves to Bundle with KEY_INTENT field in such case.

"In that case, you may need to wait until the user responds, which could take hours or days or forever. When the user does respond and supply a new password, the account manager will broadcast the LOGIN_ACCOUNTS_CHANGED_ACTION Intent, which applications can use to try again"

It works well, when thing is only about a wrong password. But I run in a problem,that AccountAuthenticator asks for permision at runtime and intent (from notification bar) starts GrantCredentialsPermissionActivity, which after user presses button (Allow or Deny) do not allow me get know that user already responded.

The question is how to get know when interection with user is finished and try again to get AuthToken.

I cant't get onActivityResult from GrantCredentialsPermissionActivity because I start it from NotificationBar (not from my other activity, as I use service while trying to get token)

I can't specify permissions in manifest beforehead, because as i understand it's some custome permissions, which defined by google authenticator.

It doesn't seem to broadcast any intent when user approve/deny requested permission for application at run-time after closing GrantCredentialsPermissionActivity. Thank you.


回答1:


Just check again in onResume that will get called even if the permission activity is a dialog. You will be asking more than needed but not excessively.




回答2:


What I think would be the best way to know when user interaction is finished is to BroadCast an event and receive it.



来源:https://stackoverflow.com/questions/5523793/google-account-authenticator-asks-for-permission-at-run-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!