简化从相册或照相获取图片的Android库:EasyImage

jopen 9年前

EasyImage是一个能够简化从相册或照相获取图片的Android库。

如何使用?

Here are buttons click listeners for picking picture from gallery or taking with camera:

@OnClick(R.id.camera_button)  protected void onTakePhotoClicked() {      EasyImage.openCamera(this);  }    @OnClick(R.id.gallery_button)  protected void onPickFromGaleryClicked() {      EasyImage.openGalleryPicker(this);  }

Now there is only one thing left to do:

@Override  protected void onActivityResult(int requestCode, int resultCode, Intent data) {      super.onActivityResult(requestCode, resultCode, data);        EasyImage.handleActivityResult(requestCode, resultCode, data, this, new EasyImage.Callbacks() {          @Override          public void onImagePickerError(Exception e, EasyImage.ImageSource source) {              //Some error handling          }            @Override          public void onImagePicked(File imageFile, EasyImage.ImageSource source) {              //Handle the image              onPhotoReturned(imageFile);          }      });  }

安装


Library requires permission from your app. Declare it in yourAndroidMnifest.xml

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Please note that for devices running API 23 (marshmallow) you have to request this permission in the runtime, beofre callingEasyImage.openCamera(). It's demonstrated in the sample app.

This library will help you with that.

repositories {      maven { url "https://jitpack.io" }  }    dependencies {      compile 'com.github.jkwiecien:EasyImage:1.0.4'  }

项目主页:http://www.open-open.com/lib/view/home/1446710908670