A tiny, fast library simplifying picture-taking on Android.
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);
}
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>
If you override onActivityResult()
or onRequestPermissionsResult()
in your activity,
please call super.onActivityResult()
or super.onRequestPermissionsResult()
for EasyCamera to work properly.
Any improvement or bug-fixing is welcome. Create a pull request when you are done.