Camera2を使って撮影した画像をImageViewに反映させたいのですが、上手くいきません。
Android機器は6.0です。
撮影をしているアクティビティの終了処理は以下でして
final CameraCaptureSession.CaptureCallback captureListener = new CameraCaptureSession.CaptureCallback() { @Override public void onCaptureCompleted(CameraCaptureSession session, CaptureRequest request, TotalCaptureResult result) { super.onCaptureCompleted(session, request, result); Toast.makeText(Camera2Activity.this, "Saved:" + file, Toast.LENGTH_SHORT).show(); Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); File f = new File(file.toString()); Uri contentUri = Uri.fromFile(f); mediaScanIntent.setData(contentUri); Intent resultIntent = new Intent(); resultIntent.putExtra("data",file.toString()); setResult(RESULT_OK, resultIntent); finish(); } };
これを呼び出し元のアクティビティにて受け取っています。
Bitmap bitmap = BitmapFactory.decodeFile(data.getStringExtra("data")); imgView.setImageBitmap(bitmap);
パーミッションはCamera、READ_EXTERNAL_STORAGE、WRITE_EXTERNAL_STORAGE
全て確認作業を実装しており、エミュレータでは無事動作したのですが、実機では失敗してしまいます。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。