我有下面的代碼:Android的意圖數據爲空
Uri imageUri = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_frontpage);
this.imageView = (ImageView) this.findViewById(R.id.pictureImageView);
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_REQUEST);
}
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) {
Bitmap photo = (Bitmap) data.getExtras().get("data");
imageView.setImageBitmap(photo);
Intent frontPageIntent = new Intent(this, FrontPageActivity.class);
imageUri = data.getData();
frontPageIntent.putExtra(URI_PATH, imageUri.toString());
frontPageIntent.putExtra("MapPhoto", photo);
startActivity(frontPageIntent);
}
}
}
它告訴我,我的data.getData();一片空白。我試過記錄它,我得到空。代碼工作之前,但現在不知何故我的程序崩潰,因爲這個值爲空,而不是圖像的uri字符串了。
任何人都可以發現我的問題嗎?
不完全確定該怎麼做? – 2014-11-04 09:45:58