我无法在 Imageview 上设置相机拍摄的图像。我也添加了权限!这是我正在使用的一段代码: B1 = (Button) findViewById(R.id.btn_camera); B1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);
}
});
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK)
{
if (requestCode == CAMERA_PIC_REQUEST)
{
Cursor cursor = getContentResolver().query(
Media.EXTERNAL_CONTENT_URI, new String[]
{
Media.DATA,
Media.DATE_ADDED,
MediaStore.Images.ImageColumns.ORIENTATION
},
Media.DATE_ADDED,
null,
"date_added ASC"
);
if (data != null)
{
if (data.hasExtra("data"))
{
Bitmap thumbnail = (Bitmap) data.getExtras().get("data");
mImageView.setImageDrawable(null);
mImageView.setImageBitmap(thumbnail);
// mImageView.postInvalidate();
}
请帮忙 !!