public synchronized void savePicPhone(final Context context, Bitmap bmp) {
FileOutputStream fos = null;
String path = Environment.getExternalStorageDirectory().getPath();
try {
// 获取系统时间
Date d = new Date();
SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String strDate = f.format(d);
File div = new File(path, "/picture");
if (!div.exists()) {
div.mkdirs(); // 不存在就创建
}
file = new File(div, strDate + "_picture.jpg");
fos = new FileOutputStream(file);
boolean compress = bmp.compress(Bitmap.CompressFormat.JPEG, 100, fos);
fos.flush();
// 发送更新图库广播
if (null != file) {
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
Uri uri = Uri.fromFile(file);
intent.setData(uri);
context.sendBroadcast(intent);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (fos != null) {
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
fos = null;
}
}
}