【发布时间】:2021-02-03 21:45:44
【问题描述】:
我正在尝试将图像上传到云火存储,代码如下:
Uri userImagePath;
FirebaseStorage storage = FirebaseStorage.getInstance();
StorageReference storageReference = storage.getReference("UserImages");
private void pickImage(View view) {
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(intent, 1);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 1 && requestCode == RESULT_OK && data.getData()!=null){
userImagePath = data.getData();
userImage.setImageURI(userImagePath);
}
}
问题是在运行应用程序时,图像未设置为 imageview。 图像选择器已打开并允许选择图像,但它不显示在 imageview 中。 没有错误显示 但在 logcat 中显示如下:
2021-02-04 03:07:12.690 22126-23476/com.example.abcd D/FA: Application going to the background
2021-02-04 03:07:14.419 22126-22126/com.example.abcd D/InputTransport: Input channel constructed: fd=64
2021-02-04 03:07:19.339 22126-23476/com.example.abcd V/FA: Inactivity, disconnecting from the service
我也做了独立缓存/重新启动,我卸载了应用程序并重新安装。但问题仍然存在。所选图像未在 imageview 中显示。
【问题讨论】:
标签: android android-studio android-intent imageview