startActivityForResult(intent, CASE_CAMERA);//调用本机的照相机
//将bitmap保存到本地
public void saveBitmap(Bitmap bm) {
// sLog.e(TAG, "保存图片");
String fileName = Environment.getExternalStorageDirectory()
+ File.separator;
File f = new File(fileName + "aaa.png");
fileyulanName = fileName + "aaa.png";
if (f.exists()) {
f.delete();
}
try {
f.createNewFile();
FileOutputStream out = new FileOutputStream(f);
bm.compress(Bitmap.CompressFormat.PNG, 90, out);
out.flush();
out.close();
// Log.i(TAG, "已经保存");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
//返回函数
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
try {
if (resultCode == Activity.RESULT_OK) {
if (requestCode == CASE_CAMERA) {
Bundle extras = data.getExtras();
Bitmap b = (Bitmap) extras.get("data");
saveBitmap(b);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}