歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> Android開發返回拍攝的圖片

Android開發返回拍攝的圖片

日期:2017/3/1 11:03:01   编辑:Linux編程

Android開發返回拍攝的圖片具體代碼如下:

  第一步:
  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());
   }
   }

Copyright © Linux教程網 All Rights Reserved