【发布时间】:2014-11-26 12:02:15
【问题描述】:
我已经完成了这个编码,一切正常,但是在我拍照后,应用程序崩溃并给出了这个错误:
11-26 13:52:32.791: E/AndroidRuntime(5321): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=100, result=-1, data=null} to activity {com.images.testimages/com.images.testimages.Test}: java.lang.NullPointerException
这是我的相机意图和 OnActivityResult:
public void onMapClick(LatLng point) {
Intent getCameraImage = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
getApplicationContext().getDir(getResources().getString(R.string.app_name), MODE_PRIVATE);
Uri imgUri = Uri.fromFile(new File((Environment.getExternalStorageDirectory() + "/" +getResources().getString(R.string.app_name)),new Date().getTime() + ".jpg"));
getCameraImage.putExtra(MediaStore.EXTRA_OUTPUT, imgUri);
startActivityForResult(getCameraImage, TAKE_PICTURE);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent) {
super.onActivityResult(requestCode, resultCode, imageReturnedIntent);
switch(requestCode) {
case TAKE_PICTURE:
if(resultCode == RESULT_OK){
Uri selectedImage = imageReturnedIntent.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 filePath = cursor.getString(columnIndex);
cursor.close();
Bitmap yourSelectedImage = BitmapFactory.decodeFile(filePath);
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
options.inSampleSize = 8;
options.inJustDecodeBounds = false;
MarkerOptions markerOptions = new MarkerOptions().position(point).icon(BitmapDescriptorFactory.fromBitmap(yourSelectedImage));
googleMap.addMarker(markerOptions);
}
}
}}
我现在不知道该怎么办?如果它是内存不足错误,那么我肯定会得到那个错误而不是这个错误吗?
有人可以帮忙吗?
【问题讨论】:
-
您的错误说明了什么?发布 logcat。
标签: android google-maps android-intent