【发布时间】:2012-10-16 08:04:38
【问题描述】:
我无法显示使用第 3 方 Android 应用程序捕获的当前图像并将其显示在我自己的本机应用程序上。它总是一个只有操作栏的空屏幕。但是,拍摄的照片可能位于我指定的文件夹中。
有人可以帮忙吗?不胜感激!干杯:)
XML 文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:id="@+id/linear">
<ImageView android:id="@+id/imageView1"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:contentDescription="@string/desc"/>
</LinearLayout>
源代码:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch(requestCode) {
case 0:
if(resultCode == Activity.RESULT_OK){
Bitmap photo = (Bitmap) data.getExtras().get("data");
imageView.setImageBitmap(photo);
}
break;
case 1:
if(resultCode == RESULT_OK){
Uri selectedImage = data.getData();
imageView.setImageURI(selectedImage);
}
break;
}
}
}
【问题讨论】:
-
第 3 方应用程序的图像存储在哪里?
-
嗨,我已将它指定在 SD 卡上 -> 图片 -> MyCreatedFolder
-
然后就可以从sdcard获取图片文件名,放到ImageView中了。就这么简单?您遇到的问题在哪里
-
嗨阿米特,我只是想知道我是否可以让上面的代码工作。在我捕获图像后它显示一个空白屏幕。
-
那么您是在选择相册然后放置图像吗??
标签: android android-layout android-intent android-emulator