Android System Photo Cropper 使用系統原生的圖片剪裁庫,完美適配魅族等機型git
First you need a sysPhotoCropper
to handle the activity results of cropping photos.github
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); sysPhotoCropper.handlerOnActivtyResult(requestCode, resultCode, data); }
Make sure you implemented these methods:ide
sysPhotoCropper = new SysPhotoCropper(this, new PhotoCropCallBack() { @Override public void onFailed(String message) { Toast.makeText(MainActivity.this,message, Toast.LENGTH_LONG).show(); } @Override public void onPhotoCropped(Uri uri) { ivResult.setImageURI(null); ivResult.setImageURI(uri); } });
Launch a request to crop photos.this
sysPhotoCropper.cropForCamera();
sysPhotoCropper.cropForGallery();