Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/212.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
IOException在Android Emulator上没有这样的文件或目录_Android_File_File Io_Ioexception - Fatal编程技术网

IOException在Android Emulator上没有这样的文件或目录

IOException在Android Emulator上没有这样的文件或目录,android,file,file-io,ioexception,Android,File,File Io,Ioexception,我看过stackoverflow的许多问题,但不幸的是,没有一个符合我的需要 我得到一个例外: 有罪类别如下: 公共类位图保存{ 私人语境; 公共静态文件; 专用静态字符串mCurrentPhotoPath; 私有静态线程threadStoreImage、threadCreateFile; 公共位图保存(上下文){ this.context=上下文; } 私有布尔isSDPresent= android.os.Environment.getExternalStorageState().equ

我看过stackoverflow的许多问题,但不幸的是,没有一个符合我的需要

我得到一个例外:

有罪类别如下:

公共类位图保存{
私人语境;
公共静态文件;
专用静态字符串mCurrentPhotoPath;
私有静态线程threadStoreImage、threadCreateFile;
公共位图保存(上下文){
this.context=上下文;
}
私有布尔isSDPresent=
android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_-MOUNTED);
/**
*拍照后存储图像
*/
公共图像库(){
如果(isSDPresent&&isExternalStorageWritable()){//检查SD卡(或新设备的内部存储器)是否存在
threadStoreImage=new线程(new Runnable()){
@凌驾
公开募捐{
Intent mediaScanIntent=新的Intent(Intent.ACTION\u MEDIA\u SCANNER\u SCAN\u文件);
文件f=新文件(mCurrentPhotoPath);
uricontenturi=Uri.fromFile(f);
mediaScanIntent.setData(contentUri);
发送广播(mediaScanIntent);
}
});
threadStoreImage.run();
Log.d(this.getClass().getSimpleName(),“threadStoreImage.run();”;
}
}
私有文件映像=null;
/**创建用于保存图像或视频的文件
*@返回
*/
公共文件createImageFile(){
//创建图像文件名
threadCreateFile=新线程(新可运行(){
@凌驾
公开募捐{
字符串时间戳=新的SimpleDateFormat(“yyyyMMdd_HHmmss”)。格式(新日期();
字符串imageFileName=“JPEG_389;”+时间戳+“389;”;
File storageDir=新文件(Environment.getExternalStorageDirectory(),“App_Name”);
试一试{
image=File.createTempFile(
imageFileName,/*前缀*/
“.jpg”,/*后缀*/
storageDir/*目录*/
);
mCurrentPhotoPath=image.getAbsolutePath();
}捕获(IOE异常){
e、 printStackTrace();
}
}
});
threadCreateFile.run();
Log.d(this.getClass().getSimpleName(),“threadCreateFile.run();”;
返回图像;
}
/*检查外部存储器是否可用于读写*/
公共布尔值isExternalStorageWritable(){
String state=Environment.getExternalStorageState();
if(环境、介质、安装等于(状态)){
返回true;
}
返回false;
}

}
您是否检查了运行时许可证第72行有哪些代码?'image=File.createTempFile(imageFileName、/*前缀/“.jpg”、/suffix/storageDir/directory*/);是的,我都查过了permissions@MatPag您有什么解决方案吗?您是否检查了运行时权限第72行有哪些代码?'image=File.createTempFile(imageFileName、/*前缀/“.jpg”、/suffix/storageDir/directory*/);是的,我都查过了permissions@MatPag你有什么解决办法吗?