Reputation: 764
I been trying for hours and hours to work where the problem is, why image uploading does not resume after I relaunch the app..
Once I select the image and start uploading it sets the session Uri and local getData uri values to shared preferences:
.addOnProgressListener(new OnProgressListener<UploadTask.TaskSnapshot>() {
@Override
public void onProgress(UploadTask.TaskSnapshot taskSnapshot) {
pBar.setVisibility(View.VISIBLE);
@SuppressWarnings("VisibleForTests") Uri sessionUri = taskSnapshot.getUploadSessionUri();
if (sessionUri != null && uploading == null) {
editor.putString("upload", sessionUri.toString()).commit();
editor.putString("local", selectedImageUri.toString()).commit();
editor.putString("ref", key).commit();
}
//calculating progress percentage
@SuppressWarnings("VisibleForTests") int bytesTransferred = (int) taskSnapshot.getBytesTransferred();
@SuppressWarnings("VisibleForTests") int totalBytes = (int) taskSnapshot.getTotalByteCount();
int progress = (100 * bytesTransferred) / totalBytes ;
pBar.setProgress(progress);
System.out.println("Uploading: " + progress);
}
});
Now If I were to kill the app, the values inside the shared reference are saved, but even the function is called for resuming the upload, nothing happens at all..
uploadTask = riversRef.putFile(Uri.parse(uploadingLocal),
new StorageMetadata.Builder().build(), Uri.parse(uploading));
I have tried to use uploadTask.pause();
or uploadTask.notify();
but nothing.
I really have no idea what the problem is..
Upvotes: 2
Views: 283
Reputation: 764
I moved the function from the onActivityResult()
to a separate void
function.
Now when I called the function I just created I received permission.MANAGE_DOCUMENTS
error which pointed me to this answer.. So basically my uri was the one causing the problem. Once relaunched app using modified intent, the uploading resumed.
Upvotes: 1