運行下面的代碼結果報錯。
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;
}
// 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;
}
mediaFile = new File.createTempFile("dsadsa", ".jpg");
改成:
mediaFile = File.createTempFile("dsadsa", ".jpg");