/**
* 打开系统相册
*/
private void openAlbum() {
Intent intent = new Intent("android.intent.action.GET_CONTENT");
intent.setType("image/*");
startActivityForResult(intent, 1004);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == RESULT_OK) {
switch (requestCode) {
case 1004:
if (Build.VERSION.SDK_INT >= 19) {//当API大于18之后Android对图片的路径进行了封装
handleImageOfKitKat(data);
} else {
handleImageBeforeKitKat(data);
}
break;
default:
break;
}
}
super.onActivityResult(requestCode, resultCode, data);
}
/**
* API 大于等于19的时候需要对返回的数据进行解析
*