我正在尝试在用户点击的那一点上显示相机拍摄的图像的标记(缩略图)的全尺寸图像。但到目前为止,图像已显示,但始终显示最新拍摄的图像,而不是点击第一个标记时拍摄的图像。
到目前为止,这是我的代码:
public void onMapLongClick(final LatLng point) {
poinOnMap=point;
googleMap.setOnInfoWindowClickListener(new OnInfoWindowClickListener() {
@Override
public void onInfoWindowClick(Marker marker) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
Uri selectedImage = intent.getData();
String[] filePathColumn = {MediaStore.Images.Media.DATA};
Cursor cursor = getContentResolver().query(
selectedImage, filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String fileUri = cursor.getString(columnIndex);
cursor.close();
bitmap = BitmapFactory.decodeFile(fileUri);
Uri imgUri = Uri.parse("file://" + bitmap + fileUri);
intent.setDataAndType(imgUri, "image/*");
startActivity(intent);
return;
}
});
getApplicationContext().getDir(
getResources().getString(R.string.app_name), MODE_PRIVATE);
fileUri = Uri.fromFile(new File((Environment.getExternalStorageDirectory() +
"/" +getResources().getString(R.string.app_name)),new Date().getTime() + ".jpg"));
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
startActivityForResult(takePictureIntent,TAKE_PICTURE);
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == TAKE_PICTURE && resultCode == RESULT_OK) {
try {
GetImageThumbnail getImageThumbnail = new GetImageThumbnail();
bitmap = getImageThumbnail.getThumbnail(fileUri, this);
} catch (FileNotFoundException e1) {
e1.printStackTrace();
} catch (IOException e1) {
e1.printStackTrace();
}
有谁能告诉我我做错了什么?
答案 0 :(得分:0)
Uri selectedImage为空
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
Uri selectedImage = intent.getData();