Android调用系统图库

//调用系统图库
Intent intent = new Intent(Intent.ACTION_PICK, null);
intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
startActivityForResult(intent, 100);



@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == RESULT_OK && requestCode == 100) {
        if (data != null) {
            Uri dataPhoto = data.getData();
            mPhoto.setImageURI(dataPhoto);
            Log.e(TAG, "===========图片地址:" + dataPhoto);
        }
    }
}

猜你喜欢

转载自blog.csdn.net/qq_36665856/article/details/79563073
今日推荐