One, foreword
Application scenario: The device takes photos periodically, uploads them to the server, and directly obtains photos
Second, the effect drawing
Three, how to use
(1) Add library
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Copy the code
Dependencies {implementation 'com. Making. Giftedcat: CameraManager: 1.0.1'}Copy the code
(2) Initialization
Manager = new CameraTakeManager(this).setrotation (0)// Sets rotation Angle. SetCompressEnable (true)// Whether compression is required. SetTakeListener (new) CameraTakeListener() { @Override public void onSuccess(File bitmapFile, Bitmap mBitmap) { imgPic.setImageBitmap(mBitmap); Tvpicdir.settext (" image path: "+ bitmapfile.getPath ()); } @Override public void onFail(String error) { LogUtil.e(error); } }).launch();Copy the code
(3) Take photos
manager.takePhoto();
Copy the code
(4) Release
manager.destroy();
Copy the code
Source code address: github.com/Giftedcat/C…