2013-11-23 57 views

回答

0

有你檢查這 Android 4.3 crop gallery resultCode Cancel

你有沒有考慮只用這樣一個圖書館:

https://github.com/biokys/cropimage

我找到com.android.camera.action.CROP有時會表現不同從手機到手機,並不總是可用的,所以如果你想要發佈它,它可能會給你帶來一些問題。

UPDATE:

我已經測試了上述庫與Android 4.3,它沒有問題的作品。您只需將庫添加到您的項目。

然後你可以寫你的方法非常相似的方式:

private void performCrop(Uri picUri) { 
//you have to convert picUri to string and remove the "file://" to work as a path for this library 
String path = picUri.toString().replaceAll("file://", ""); 

try { 
    int aspectX = 750; 
    int aspectY = 1011; 

    Intent intent = new Intent(this, CropImage.class); 
    //send the path to CropImage intent to get the photo you have just taken or selected from gallery 
    intent.putExtra(CropImage.IMAGE_PATH, path); 

    intent.putExtra(CropImage.SCALE, true); 

    intent.putExtra("aspectX", aspectX); 
    intent.putExtra("aspectY", aspectY); 

    intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(mCurrentPhotoPath))); 

    startActivityForResult(intent, CROP); 
} 
catch (ActivityNotFoundException anfe) { 
    String errorMessage = "Your device doesn't support the crop action!"; 
    Toast toast = Toast.makeText(this, errorMessage, Toast.LENGTH_SHORT); 
    toast.show(); 
} 

}

+0

好啊。我對你有mentioned.But圖書館工作,我想知道如何獲得的名稱Android設備使用的包。最好是實現Android設備使用的「默認裁剪功能」。 –

+0

我不確定是否有辦法根據它們執行的操作來查找特定的類包。 但是通過在圖像URI上使用「ACTION_VIEW」或用「image/*」指定類型將列出可以打開或操作的所有選項。 – vinaykumar

+0

你甚至可以設置裁剪圖像的選項,同時選擇圖像或從相機捕獲圖像,而不需要其他時間調用「裁剪」 – vinaykumar

相關問題