There is an example of how to use Drive API https://developers.google.com/drive/quickstart-android. It works well, but I have some trouble while trying to implement uploading file to GDrive from background service.
In all examples which I found, in case when we receive UserRecoverableAuthException
we need to start new Activity using Intent from that Exception (UserRecoverableAuthException#getIntent()
) to take user to the OAuth2 permission page.
When we do this from Activity, we just use startActivityForResult
, and as result we can use onActivityResult
to know that the user finished his interaction and we can retry.
But in case, if I want to work with Drive API from Service, and there is user interaction needed, all I can do is provide Notification to user with PendingIntent. And there is no any callback for me to know when user closes OAuth2 permission page.
Can you please suggest any approach to this? Maybe I miss something? Maybe there is some broadcast I have to catch or etc?
Thank you.