1 year ago
#366530
Ilianto
Wrong resultCode on poco phone
Uploading an image to firebase. There is no problem when downloading from android emulator or oppo phone, but when starting the project from poco m3 phone, no upload occurs.
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == RC_IMAGE_PICKER&& resultCode == RESULT_OK){ Uri selectedImageUri = data.getData(); StorageReference imageReference = chatImagesStorageReference.child(selectedImageUri.getLastPathSegment()); UploadTask uploadTask = imageReference.putFile(selectedImageUri); uploadTask = imageReference.putFile(selectedImageUri);
Task<Uri> urlTask = uploadTask.continueWithTask(new Continuation<UploadTask.TaskSnapshot, Task<Uri>>() {
@Override
public Task<Uri> then(@NonNull Task<UploadTask.TaskSnapshot> task) throws Exception {
if (!task.isSuccessful()) {
throw task.getException();
}
// Continue with the task to get the download URL
return imageReference.getDownloadUrl();
}
}).addOnCompleteListener(new OnCompleteListener<Uri>() {
@Override
public void onComplete(@NonNull Task<Uri> task) {
if (task.isSuccessful()) {
Uri downloadUri = task.getResult();
AwesomeMessage message = new AwesomeMessage();
message.setImageUrl(downloadUri.toString());
message.setName(userName);
messagesDatabaseReferences.push().setValue(message);
} else {
// Handle failures
// ...
}
}
});
}
By trial, I determined that when starting from the phone, resultCode = 0, with which I can’t understand it connected. Everything else except resultCode works properly.
When running the application on the android emulator or on oppo , there were no problems, the pictures were sent, but nothing happened when sending from the poco m3.
java
firebase-realtime-database
xiaomi
0 Answers
Your Answer