1

I'm using google adrive api version 3 library in android. uploading a file is not an issue, but am not getting media in progress value to show progress bar. My code is,

Drive.Files.Create create = mService.files().create(file, mediaContent);
MediaHttpUploader uploader = create.getMediaHttpUploader();
uploader.setDirectUploadEnabled(false);
uploader.setProgressListener(new MediaHttpUploaderProgressListener() {
    @Override
    public void progressChanged(MediaHttpUploader uploader) throws IOException {
        Intent intent = new Intent(AuthPreferences.DRIVE_FILE_UPLOAD_PROGRESS_LISTENER);
        switch (uploader.getUploadState()) {
            case INITIATION_STARTED:
                //postToDialog("Initiation Started");
                break;
            case INITIATION_COMPLETE:
                //postToDialog("Initiation Completed");
                break;
            case MEDIA_IN_PROGRESS:
                // postToDialog("Upload in progress");
                intent.putExtra(AuthPreferences.DRIVE_FILE_UPLOAD_PROGRESS, (int) uploader.getProgress());
                break;
            case MEDIA_COMPLETE:
                //postToDialog("Upload Completed!");
                intent.putExtra(AuthPreferences.DRIVE_FILE_UPLOAD_PROGRESS, 100);
                break;
            case NOT_STARTED:
                //postToDialog("Not Started!");
                break;
        }
        sendBroadcast(intent);
    }
});
file = create.execute();

In this, it is firing INITIATION_STARTED, MEDIA_COMPLETE but not getting MEDIA_IN_PROGRESS. I have also gave chunkSize but no use. I have tried setDirectUploadEnabled both true & false but no use. It is not working. Is there any problem in version 3 API.

0 Answers0