为什么在我的方法onActivityResult中它没有达到else-if条件。我想使用UCrop 将裁剪后的图像保存到firebase
Uri imageUriResuktCrop;
@Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK && requestCode == CODE_IMG_GALLERY) {
imageUri = data.getData();
if (imageUri != null) {
startCrop(imageUri);
}
} else if (resultCode == RESULT_OK && requestCode == UCrop.REQUEST_CROP ) {
imageUriResuktCrop = UCrop.getOutput(data);
if (imageUriResuktCrop != null) {
img.setImageURI(imageUriResuktCrop);
}
}
if (!currentImg.toString().equals("")) {
StorageReference delRef = FirebaseStorage.getInstance().getReferenceFromUrl(currentImg.toString());
delRef.delete().addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
}
});
}
StorageReference mStorageRef = FirebaseStorage.getInstance().getReference("uploads").child("gallery");
fileRef = mStorageRef.child(FirebaseAuth.getInstance().getCurrentUser().getUid()).child(System.currentTimeMillis() + "." + getFileExtension(imageUriResuktCrop));
StorageTask mUploadTask = fileRef.putFile(imageUriResuktCrop)
.addOnSuccessListener((OnSuccessListener<UploadTask.TaskSnapshot>) taskSnapshot -> {
fileRef.getDownloadUrl().addOnSuccessListener(uri -> {
//code here
}
结果发送活动未将结果设置为result_OK。取消检查以验证结果