PictureCallback jpegCallback = new PictureCallback() {
public void onPictureTaken(byte[] data, Camera camera) {
FileOutputStream outStream = null;
try {
// Write to SD Card
fileName = String.format("%d.jpg", System.currentTimeMillis());
File file = new File(Environment.getExternalStorageDirectory().getPath()+"/camtest");
if(!file.exists())
file.mkdirs();
File outputFile = new File(file, fileName);
outStream = new FileOutputStream(outputFile);
outStream.write(data);
outStream.close();
Log.d(TAG, "onPictureTaken - wrote bytes: " + data.length);
resetCam();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
}
Log.d(TAG, "onPictureTaken - jpeg");
}
};
使用此代码我可以存储到设备存储中。无法在Android上写入外部SD卡
DeviceStorage /仿真/ 0/camtest
我想它存储到外置SD卡。我如何做到这一点
我有以下权限
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
确保设备在测试时不通过USB进行根。 – Hank
嗨@Hank没有我的设备没有根植 – user2626445
它记录写过的字节行吗? – superfell