I'm trying to put extras (string) in an intent. I use startActivityForResult and onActivityResult to get my extras on the other side.
But I can't get why it doesn't works ! Here's my code :
buttonCamera.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra("abc", "test");
startActivityForResult(intent, PHOTO_RESULT);
}
});
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == PHOTO_RESULT) {
if (resultCode == RESULT_OK) {
Bundle extras = data.getExtras();
if (extras != null) {
String abc = extras.getString("abc");
Toast.makeText(getApplicationContext(), abc, Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getApplicationContext(), "can't get", Toast.LENGTH_SHORT).show();
}
}
}
}
I always get an empty toast, so the extra is not null.. But I cant't get the String..
Thanks !