2013-10-19 35 views
2

我試圖在將uri傳遞給相機意圖時將完整的相機圖像保存到指定的Uri。但它不返回onActvityResult。但是,我已經嘗試使用onActivityResult中的Bundle獲取圖像,但它會返回縮略圖。我已經嘗試了很多教程,他們都有這個問題。可以請你幫忙!!!下面給出Android相機意圖不會返回到onActivityResult

  Intent camera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); 
      File u = getTempFile(); 
      picUri = Uri.fromFile(u); 
      camera.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(u)); 

      startActivityForResult(camera, TAKE_PICTURE); 

onActivityResult

  if (requestCode == TAKE_PICTURE && resultCode == RESULT_OK && null != data) 
      { 
      Toast.makeText(this, "Image saved to:\n"+picUri, Toast.LENGTH_LONG).show(); 
      } 
+0

沒有發現這方面的任何解決辦法呢。請幫忙!!! – yaloumi

回答

0

try代碼:

   Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); 
       File f = new File(android.os.Environment 
         .getExternalStorageDirectory(), "temp.jpg"); 

       intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f)); 
       startActivityForResult(intent, REQUEST_CAMERA); 


       protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
        super.onActivityResult(requestCode, resultCode, data); 
        if (resultCode == RESULT_OK) { 
         if (requestCode == REQUEST_CAMERA) { 

         File f = new File(Environment.getExternalStorageDirectory() 
         .toString()); 

       for (File temp : f.listFiles()) { 
       if (temp.getName().equals("temp.jpg")) { 
        f = temp; 
        break; 
         } 
        } 

       String path = f.getAbsolutePath(); 
    } } 

    } 
+0

沒有工作。無論如何感謝您的幫助。 – yaloumi