我正在尝试按照本教程进行操作,但是问题是当我单击应该确认图像的复选标记时,它根本没有做任何事情。我觉得我缺少某种访问 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"
}
}