第三方库:https://github.com/crazycodeboy/TakePhoto
支持照片裁剪,批量选择图片,压缩图片
代码如下:
package com.xxxx.xxxxx;
public class BaseActivity extends TakePhotoActivity
{
// Setup activity layout
@Override protected void onCreate(Bundle savedInstanceState)
{
}
//获取手机图片
public void takePhoto(int photoType)
{
Log.d("BaseActivity", "takePhoto");
File file = new File(Environment.getExternalStorageDirectory(), "/test/" + System.currentTimeMillis() + ".jpg");
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
Uri imageUri = Uri.fromFile(file);
this.getTakePhoto().onPickFromCapture(imageUri);
}
@Override
public void takeCancel() {
super.takeCancel();
}
@Override
public void takeFail(TResult result, String msg) {
super.takeFail(result, msg);
}
@Override
public void takeSuccess(TResult result) {
super.takeSuccess(result);
}
}
网友评论