Java 图像捕获意图永远不会返回onActivityResult(int,int,Intent);
我启动了一个像这样的Java 图像捕获意图永远不会返回onActivityResult(int,int,Intent);,java,android,Java,Android,我启动了一个像这样的图像捕获意图,我的活动的onActivityResult()被调用: Intent i = new Intent (android.provider.MediaStore.ACTION_IMAGE_CAPTURE, null); i.putExtra("return-data", true); startActivityForResult(i, PICK_ICON_FROM_CAMERA_ID); Intent i = new Intent (android.provide
图像捕获
意图,我的活动的onActivityResult()
被调用:
Intent i = new Intent (android.provider.MediaStore.ACTION_IMAGE_CAPTURE, null);
i.putExtra("return-data", true);
startActivityForResult(i, PICK_ICON_FROM_CAMERA_ID);
Intent i = new Intent (android.provider.MediaStore.ACTION_IMAGE_CAPTURE, null);
i.putExtra(MediaStore.EXTRA_OUTPUT, Uri.parse("file:/" + "MyTestFile"));
i.putExtra("outputFormat", Bitmap.CompressFormat.PNG.name());
startActivityForResult(i, PICK_ICON_FROM_CAMERA_ID);
但是,如果我这样开始我的意图,捕获图像意图确实会被调用,但我的活动的onActivityResult()
从未被调用:
Intent i = new Intent (android.provider.MediaStore.ACTION_IMAGE_CAPTURE, null);
i.putExtra("return-data", true);
startActivityForResult(i, PICK_ICON_FROM_CAMERA_ID);
Intent i = new Intent (android.provider.MediaStore.ACTION_IMAGE_CAPTURE, null);
i.putExtra(MediaStore.EXTRA_OUTPUT, Uri.parse("file:/" + "MyTestFile"));
i.putExtra("outputFormat", Bitmap.CompressFormat.PNG.name());
startActivityForResult(i, PICK_ICON_FROM_CAMERA_ID);
您能告诉我如何让第二个案例工作吗?我认为“file:/MyTestFile”是一个不正确的uri。试试这样:
File f=new File(Environment.getExternalStorageDirectory(), "MyTestFile");
intent.putExtra(MediaStore.EXTRA_OUTPUT,Uri.fromFile(f));
实际路径为“/sdcard/MyTestFile”