【发布时间】:2017-07-13 13:21:46
【问题描述】:
这可能是一个老问题,但我找不到任何解决方案。所以再问一遍
我正在尝试捕获图像并将其存储在内部存储中,并在我的应用程序中使用后将其删除。它在除三星 Note 3 之外的所有设备上都能正常工作。
private void captureImage() {
try {
if(photoPath!=null) {
new File(photoPath).delete();
photoPath = null;
}
//SET THE IMAGE NAME AND IMAGE PATH FOR THE CURRENT IMAGE
final Random random = new Random();
photoPath = getPath(this)+"/img" + String.valueOf(random.nextInt()) + ".jpg";
final Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
final File imageStorage = new File(photoPath);
if (imageStorage != null) {
//to capture full image use URI otherwise use filepath
Uri photoURI = FileProvider.getUriForFile(this, "<<my path>>.fileprovider", imageStorage);
intent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
startActivityForResult(intent, Constants.ACTION_CAMERA_REQUEST);
}
}
catch (Throwable e) {
}
}
我在这里缺少什么。谁能帮帮我
【问题讨论】:
-
试试this 链接上的代码。效果很好!
标签: android android-camera samsung-mobile samsung-galaxy