2013-08-12 2 views
0

안녕하세요, 사용자가 이미지 및 자르기를 허용하는이 앱이 있습니다. 그것은 내 휴대폰에서 작동하지만 내 삼성 갤럭시 타블렛에서는 작동하지 않습니다. 은 "이미지 저장"대화 상자가 그냥 작물을 취소 할 경우는 반환하지 ... 내 응용 프로그램의 onActivityResult를로 돌아 남아 있지 [안드로이드 타블렛은 자르기 후 인 텐트로 돌아갈 수 없습니다.

@Override 
protected void onActivityResult(int requestCode, int resultCode, Intent data) { 

    if (resultCode == RESULT_OK) { 
     if (requestCode == 1337 && resultCode == -1) { 
      File fi = new File("/sdcard/tmp"); 
      // get the Uri for the captured image - NEW 
      try { 
       mImageCaptureUri = Uri 
         .parse(android.provider.MediaStore.Images.Media 
           .insertImage(getContentResolver(), 
             fi.getAbsolutePath(), null, null)); 

       // Log.i("",String.valueOf(thumbnail.getHeight())); 

      } catch (Exception ex) { 
       String errorMessage = "Your device doesn't support the crop action!"; 
       Toast toast = Toast.makeText(this, errorMessage, 
         Toast.LENGTH_SHORT); 
       toast.show(); 
      } 
      performCrop(); 
     } 
     if (requestCode == PIC_CROP) { 
      try { 
       final TextView imgTv = (TextView) findViewById(R.id.info); 
       // Bundle extras = data.getExtras(); 
       // thumbnail = extras.getParcelable("data"); 
       Log.i("a", "test"); 
       // NEW 
       final String filePath = Environment.getExternalStorageDirectory() 
         + "/temporary_holder.jpg"; 

       thumbnail = BitmapFactory.decodeFile(filePath); 


       ImageView image = (ImageView) findViewById(R.id.img); 
       image.setImageBitmap(thumbnail); 

}}

private void performCrop() { 
    try { 
     // call the standard crop action intent (the user device may not 
     // support it) 
     Intent cropIntent = new Intent("com.android.camera.action.CROP"); 
     // indicate image type and Uri 
     cropIntent.setDataAndType(mImageCaptureUri, "image/*"); 
     // set crop properties 
     cropIntent.putExtra("crop", "true"); 
     // indicate aspect of desired crop 
     cropIntent.putExtra("aspectX", 4); 
     cropIntent.putExtra("aspectY", 3); 
     // indicate output X and Y 
     cropIntent.putExtra("outputX", 500); 
     cropIntent.putExtra("outputY", 300); 
     // retrieve data on return 
     // cropIntent.putExtra("return-data", true); 

     File f = new File(Environment.getExternalStorageDirectory(), 
       "/temporary_holder.jpg"); 
     try { 
      f.createNewFile(); 
     } catch (IOException ex) { 
      Log.e("io", ex.getMessage()); 
     } 
     uri = Uri.fromFile(f); 
     cropIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri); 

     startActivityForResult(cropIntent, PIC_CROP); 

    } // respond to users whose devices do not support the crop action 
    catch (ActivityNotFoundException anfe) { 
     // display an error message 
     String errorMessage = "Your device doesn't support the crop action!"; 
     Toast toast = Toast 
       .makeText(this, errorMessage, Toast.LENGTH_SHORT); 
     toast.show(); 
    } 
} 

답변

4

더 나은 솔루션에 대한 링크 다음을 참조하십시오 :

Link 1

Link 2

관련 문제