1

I need to show progress dialog when Google drive app downloads file content from web. I used Intent.ACION_GET_CONTENT to get files from Google Drive. The problem is Drive app takes too much time to download the file content and at that time my app looks like it got stuck at somewhere. Sorry for my bad english.

This is my intent

Intent getContentIntent = new Intent(Intent.ACTION_GET_CONTENT);
getContentIntent.addCategory(Intent.CATEGORY_OPENABLE);
getContentIntent.setType("text/plain"); 
String [] mimeTypes={"application/vnd.oasis.opendocument.text","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.wordprocessingml.template","application/vnd.ms-word.document.macroEnabled.12","application/vnd.ms-word.template.macroEnabled.12","text/plain"};
                                    getContentIntent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes);
                                    Intent intent = Intent.createChooser(getContentIntent, "Import Document"); 
                                    activity.startActivityForResult(intent, com.test.app.Constants.REQUESTCODES.FILE_CHOOSER.getValue());

Thanks in advance.

Vijay
  • 545
  • 1
  • 5
  • 15

1 Answers1

0

From the Drive API documentation, it says here that opening a file may require a long I/O operation if the file is not yet synced locally. You can attach a DownloadProgressListener to inform users of the download progress in a ProgressDialog to improve the user experience. To listen to the download progress, open the file contents with a DownloadProgressListener. For full working sample code, check this github.

For more information, you can also check these SO questions:

Community
  • 1
  • 1
KENdi
  • 7,576
  • 2
  • 16
  • 31