我尝试使用 Glass Camera 显示捕获的图像并将其显示在 ImageView 中。
这就是我现在所做的:
public void startCamera()
{
Intent captureIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(captureIntent, 100);
}
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 100 && resultCode == RESULT_OK && null != data)
{
String photoPath = data.getExtras().getString("picture_file_path");
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
bitmap = BitmapFactory.decodeFile(photoPath, options);
mImageView.setImageBitmap(bitmap);
}
}
但是位图为空。当我记录 photoPath 时,它会给我一个文件路径,例如:
/mnt/sdcard/DCIM/Camera/20131216_195521_665.jpg
有任何想法吗?