이 튜토리얼을 따르려고하지만 이미지를 확인해야하는 체크 표시를 클릭하면 문제가 발생합니다. SD 카드 나 뭔가에 액세스 할 수있는 권한이없는 것 같습니다. 디버그 모드에서 nexus 7을 테스트하고 있습니다. 모든 도움을 주셔서 감사합니다.카메라 의도를 사용하여 안드로이드에 비트 맵 저장하기
public class MainActivity extends Activity {
private static final int CAMERA_REQUEST = 1888;
private static ImageView imageView;
protected String _path;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
this.imageView = (ImageView)this.findViewById(R.id.imageView1);
Button photoButton = (Button) this.findViewById(R.id.button1);
_path = Environment.getExternalStorageDirectory() + "/images/camocr";
photoButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
File file = new File(_path);
Uri outputFileUri = Uri.fromFile(file);
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
//Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, 0);
}
});
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == -1) {
// Bitmap photo = (Bitmap) data.getExtras().get("data");
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 4;
Bitmap bitmap = BitmapFactory.decodeFile(_path, options);
imageView.setImageBitmap(bitmap);
}
}
protected static void identifyunicode() {
// DATA_PATH = Path to the storage
// lang for which the language data exists, usually "eng"
}
}
요청 코드를 0으로 설정하고 onActivityResult에서 -1을 확인합니다. – JRowan