解决方法
提高动作意图为ACTION_GET_CONTENT,并将类型设置为“image / *”.这将启动照片选择器活动.当用户选择图像时,可以使用onActivityResult回调来获取结果.
就像是:
Intent photoPickerIntent = new Intent(Intent.ACTION_GET_CONTENT); photoPickerIntent.setType("image/*"); startActivityForResult(photoPickerIntent,1); protected void onActivityResult(int requestCode,int resultCode,Intent data) { super.onActivityResult(requestCode,resultCode,data); if (resultCode == RESULT_OK) { Uri chosenImageUri = data.getData(); Bitmap mBitmap = null; mBitmap = Media.getBitmap(this.getContentResolver(),chosenImageUri); } }