There is an example of using the Drive API https://developers.google.com/drive/quickstart-android . It works well, but I have some problems when trying to implement uploading a file to GDrive from the background service.
In all the examples that I found, in the case where we get UserRecoverableAuthException, we need to start a new operation using the Intent from this Exception ( UserRecoverableAuthException#getIntent()) in order to go to the OAuth2 permission page.
When we do this from Activity, we simply use it startActivityForResult, and as a result, we can use onActivityResultit to find out that the user has completed his interaction, and we can try again.
But in case I want to work with the API Disk from the Service, and user interaction is required, all I can do is provide a notification to the user with PendingIntent. And there is no callback for me to find out when the user closes the OAuth2 permission page.
Could you suggest any approach to this? Maybe I missed something? Maybe there is some kind of broadcast that I have to catch, etc.?
Thank.
Denys source
share