The following code allows me to take pictures, however it does not insert the image into the db. What am I missing?
Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
ContentValues values = new ContentValues();
values.put(Media.TITLE, "Image");
values.put(Images.Media.BUCKET_ID, "292");
values.put(Images.Media.BUCKET_DISPLAY_NAME, "thename");
values.put(Images.Media.MIME_TYPE, "image/jpeg");
values.put(Media.DESCRIPTION, "Im开发者_开发问答age capture by camera");
values.put("_data", IMG_FILE_PATH);
Uri uri = getContentResolver().insert( Media.EXTERNAL_CONTENT_URI , values);
i.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, uri);
i.putExtra("return-data", true);
startActivityForResult(i,REQ_PHOTO);
Uri uri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
new ContentValues());
Intent imageIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
imageIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
startActivityForResult(imageIntent, REQUEST_CODE_CAPTURE_IMAGE_ACTIVITY);
Try just using this code. It seems like you overwriting _data is causing issues when Android tries to store the image.
精彩评论