如何從捆綁獲取URI?我已經嘗試了下面的代碼,但data.getExtras();會給出錯誤,data.getData()會給出null。從捆綁獲取URI
Intent intent = new Intent(Intent.ACTION_PICK,
MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
intent.setType("image/*");
intent.putExtra("scale", true);
intent.putExtra("crop", "true");
intent.putExtra("outputX", 256);
intent.putExtra("outputY", 256);
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
intent.putExtra("return-data", true);
startActivityForResult(intent, 1);
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 1) {
final Uri imageUri = data.getExtras();
final Uri imageUri = data.getData();
}
}
退房[這](https://stackoverflow.com/questions/4233873/how-do-i-獲取額外的數據從意圖在Android)答案。 –
data.getExtras()給出一個Bundle,docs說uri在getData()中,但是你必須設置intent.setAction(Intent.ACTION_GET_CONTENT); –