这是开发过程中发现的一个宝藏相机,调用简单,界面美观,功能齐全,记录在此,以供后用
依赖
权限
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.CAMERA"/>
依赖
implementation 'com.github.wildma:PictureSelector:2.1.0'
在项目的build.gradle添加JitPack仓库
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
使用
PictureSelector
.create(publishActivity.this, PictureSelector.SELECT_REQUEST_CODE)
.selectPicture(true, 118, 82, 3, 2);
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == PictureSelector.SELECT_REQUEST_CODE) {
if (data != null) {
String picturePath = data.getStringExtra(PictureSelector.PICTURE_PATH);
}
}
}
|