我想从相机捕捉图像并保存到我自己的路径,而不是DCIM文件夹。
我已经尝试了Stackoverflow的几乎所有答案,但我还没有得到任何解决方案。
错误:
12-26 19:49:39.520:W / System.err(25861):java.lang.NullPointerException 12-26 19:49:39.550:W / System.err(25861):at java.io.File.fixSlashes(File.java:185) 12-26 19:49:39.550:W / System.err(25861):at java.io.File。(File.java:134)
public String finalimagepath = Environment.getExternalStorageDirectory() + "";
private static final int CAMERA_CAPTURE_IMAGE_REQUEST_CODE = 100;
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
String randomvalue = String.valueOf(System.currentTimeMillis()) + ".png";
File f = new File(finalimagepath, randomvalue);
finalimagefullpath = finalimagepath + "/" + randomvalue;
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f));
startActivityForResult(intent, CAMERA_CAPTURE_IMAGE_REQUEST_CODE);