现在的位置: 首页 > 综合 > 正文

Android开发返回拍摄的图片

2011年11月21日 ⁄ 综合 ⁄ 共 599字 ⁄ 字号 评论关闭
具体代码如下:
第一步:
try {
  Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
      startActivityForResult(intent, 0);
  } catch (ActivityNotFoundException e) {
   // Do nothing for now
  }
第二步:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   try {
   if (requestCode != 0) {
    return;
   }
   super.onActivityResult(requestCode, resultCode, data);
   Bundle extras = data.getExtras();
   Bitmap b = (Bitmap) extras.get("data");
   ImageView a = (ImageView)findViewById(R.id.imageView1);
   a.setImageBitmap(b);
   //
   /*
    * 得到图片对图片处理...
    */
  } catch (Exception e) {
   // TODO: handle exception
   System.out.println(e.getMessage());
  }

抱歉!评论已关闭.