/EasyCamera

A tiny, fast library simplifying picture-taking on Android

Primary LanguageJavaMIT LicenseMIT

EasyCamera

auc api repository License

A tiny, fast library simplifying picture-taking on Android.

Usage in 3 steps

1. Extend your Activity with EasyCameraActivity:

public class MainActivity extends EasyCameraActivity {
  // ...
}

2. Call openCamera() and inject a CameraListener:

  openCamera(new CameraListener() {
    @Override
    public void onPictureTaken(String picturePath) {
      // Proceed with picturePath, the path to the picture taken just now.
    }
    @Override
    public void onCancelled() {
      // ...
    }
  });

By default, The picturePath is Environment.DIRECTORY_DCIM/{Your App Name}/{Random Filename}.jpg. It can be customized by an optional argument of openCamera().

3. Do something with the picture - for example:

@Override
public void onPictureTaken(String picturePath) {
  // add the picture to the system gallery.
  EasyCameraUtils.galleryAddPicture(getApplicationContext(), picturePath);

  // load the picture into an ImageView.
  EasyCameraUtils.loadPicture(imageView, picturePath);
}

Add EasyCamera to your project

Via Gradle:

implementation 'ink.envoy.easycamera:easycamera:0.2.0'

Via Maven:

<dependency>
  <groupId>ink.envoy.easycamera</groupId>
  <artifactId>easycamera</artifactId>
  <version>0.2.0</version>
  <type>pom</type>
</dependency>

Pay Attention

If you override onActivityResult() or onRequestPermissionsResult() in your activity, please call super.onActivityResult() or super.onRequestPermissionsResult() for EasyCamera to work properly.

Contributing

Any improvement or bug-fixing is welcome. Create a pull request when you are done.

License

The MIT License