报错:cannot resolve symbol createTempFile
0
运行下面的代码结果报错。
cannot resolve symbol createTempFile
代码:
import java.io.File;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.view.View;
public final class Util
{
static Bitmap image;
public static File getOutputMediaFile(byte[] data)
{
image= BitmapFactory.decodeByteArray(data, 0, data.length);
File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "FrontFlash");
// Create the storage directory if it does not exist
if (!mediaStorageDir.exists())
{
if (!mediaStorageDir.mkdirs()) return null;
}//www.sctarena.com
// Create a media file name
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
File mediaFile=null;
//mediaFile = new File(mediaStorageDir.getPath() + File.separator + "IMG_" + timeStamp + ".jpg");
mediaFile = new File.createTempFile("dsadsa", ".jpg");
return mediaFile;
}
cannot resolve symbol createTempFile
代码:
import java.io.File;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.view.View;
public final class Util
{
static Bitmap image;
public static File getOutputMediaFile(byte[] data)
{
image= BitmapFactory.decodeByteArray(data, 0, data.length);
File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "FrontFlash");
// Create the storage directory if it does not exist
if (!mediaStorageDir.exists())
{
if (!mediaStorageDir.mkdirs()) return null;
}//www.sctarena.com
// Create a media file name
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
File mediaFile=null;
//mediaFile = new File(mediaStorageDir.getPath() + File.separator + "IMG_" + timeStamp + ".jpg");
mediaFile = new File.createTempFile("dsadsa", ".jpg");
return mediaFile;
}