从相册中打开特定图像
我正在制作一个简单的 Android 应用程序,我想从我的应用程序中拍摄一张图像并将其保存在相册中。拍摄图像后,我在数据库中获取“requestCode”(saveImageId)。
public void makePicture(){
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_PIC_ID);
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CAMERA_PIC_ID) {
Bitmap thumbnail = (Bitmap)data.getExtras().get("data");
Log.d("picture receive","foto ok?");
saveImageId = requestCode;
_ivPicture.setImageBitmap(thumbnail);
}
}
当我想显示图像时,我从数据库中读取代码。我必须使用 requestCode 搜索图像并将其显示给用户。
有人知道如何在 _ivPicture 中显示图像吗? 问候
I'm making a simple Android app and from my app I want to take an image and save it in the album. After the image is taken I take the 'requestCode' in a database (saveImageId).
public void makePicture(){
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_PIC_ID);
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CAMERA_PIC_ID) {
Bitmap thumbnail = (Bitmap)data.getExtras().get("data");
Log.d("picture receive","foto ok?");
saveImageId = requestCode;
_ivPicture.setImageBitmap(thumbnail);
}
}
When I want to show the image I read the code out of the database. I have to search the image with the requestCode and show it to the user.
Anyone got any idea how I can show the image in the _ivPicture?
Regards
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
找到了,
必须保存图片的位置:
saveImageId 将进入数据库(作为字符串),之后我必须使用以下命令再次加载图像:
Uri myUri = Uri.parse(saveImageId);
_ivPicture.setImageURI(myUri);
Found it,
had to save the place of the picture:
the saveImageId is going to the database (as a string), afterwards I had to load the image again with :
Uri myUri = Uri.parse(saveImageId);
_ivPicture.setImageURI(myUri);
我认为您需要更正上面代码的主要部分。
I think you need to correct the main part of your code above.