我嘗試服用後裁剪圖像後,裁剪圖像,我的代碼如下:安卓:把它帶攝像頭與一個固定長寬比
private void doTakePhotoAction() {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, MediaStore.Images.Media.EXTERNAL_CONTENT_URI.toString());
intent.putExtra("crop", "true");
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
intent.putExtra("outputX", 96);
intent.putExtra("outputY", 96);
try {
intent.putExtra("return-data", true);
startActivityForResult(intent, PICK_FROM_CAMERA);
} catch (ActivityNotFoundException e) {
//Do nothing for now
}
}
與上面的代碼,我能夠進入裁剪模式,裁剪照片。但是,1:1寬高比不是強制執行的,outputX和outputY都不是。我相信這是因爲其意圖是爲了拍攝照片,而不是種植。我也寫的另一種方法,從意向的getData(),之後使用以下命令:
Intent intent = new Intent("com.android.camera.action.CROP");
intent.setClassName("com.android.camera", "com.android.camera.CropImage");
然而,當我這樣做,我得到以下運行時錯誤:
E/AndroidRuntime(14648): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.camera/com.android.camera.CropImage}: java.lang.NullPointerException
謝謝您的幫助! :)
對我來說不起作用:android.content.ActivityNotFoundException:沒有找到處理Intent的活動{act = android.intent.action.GET_CONTENT(has extras)} – stoefln 2014-10-14 16:16:38