Reputation: 705
I'm trying to pass on a file location and an id via the intent of the camera after taking a picture.
That happens in this code:
btaddphoto.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Integer vraagnr = Integer.parseInt(lblQuestionNr.getText().toString());
String _path = Environment.getExternalStorageDirectory().toString() + File.separator + "photo_" + vraagnr.toString() + ".png";
File file = new File(_path);
Uri outputFileUri = Uri.fromFile(file);
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
intent.putExtra("view", newview.Id);
((Activity) ctx).startActivityForResult(intent, newview.Id);
}
});
In this code the intent exists, aka is not null.
In this code data is null:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
}
Why is data null? Is it not the same Intent as the Intent in the OnClick event?
rg, Eric
Upvotes: 1
Views: 426
Reputation: 68167
No, this is not the same Intent
as you sent in the onClick event. This Intent
is returned as response from camera activity (i.e. android.media.action.IMAGE_CAPTURE). Here (in onActivityResult) you need to check if the data object is null
then there's no data returned from the camera activity.
Upvotes: 2