我应该怎样做才能获得拍摄图像的拍照。这样我可以在第二个活动中显示它作为drawable? 第一项活动
btn_cam.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
file = new File(MainActivity.this.getExternalCacheDir(),
String.valueOf(System.currentTimeMillis()) + ".jpg");
fileUri = Uri.fromFile(file);
intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
MainActivity.this.startActivityForResult(intent, CAMERA_PIC_REQUEST);
}
});
}
protected void onActivityResult(int requestCode, int resultCode, Intent resultData) {
if (requestCode == CAMERA_PIC_REQUEST && resultCode == RESULT_OK) {
fileUri = data.getData();
Intent cam = new Intent(this, MainCam.class);
cam.putExtra("flostic", fileUri.toString());
startActivity(cam);
this.finish();
第二次活动
String image_path = getIntent().getStringExtra("flostic");
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
Bitmap bitmap = BitmapFactory.decodeFile(image_path, options);
view.setImageBitmap(bitmap);