views:

149

answers:

2

I have this code:

Intent intent = new Intent();
        intent.setAction(Intent.ACTION_PICK);
        intent.setData(ContactsContract.Contacts.CONTENT_URI);
        intent.putExtra(EXTRA_ONLINE_ID, (String) v.getTag());
        startActivityForResult(intent, PICK_CONTACT);

Then on response:

public void onActivityResult(int reqCode, int resultCode, Intent data) {


        switch (reqCode) {
            case (PICK_CONTACT):
                if (resultCode == Activity.RESULT_OK) {
                    try {
                        Uri contactData = data.getData();
                        String onlineid = data.getStringExtra(EXTRA_ONLINE_ID);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                break;
        }
        super.onActivityResult(reqCode, resultCode, data);
    }

the onlineid variable is null, how can I pass a value and then to receive it back?

EDIT

I even tried,

Bundle extras = data.getExtras(); // returns null
A: 

ok Check if your Activity android:launchMode is configured as SingleTask or SingleInstance! that must be the problem :)

Jorgesys
This does not help.
Pentium10
Hi Pentium10, did you solve this? I think everything is ok in your code :S
Jorgesys
@Jorgesys I did not resolved. I think that the custom extras we pass to that other activity is not retained.
Pentium10
A: 

I was running into some problems with this as well.

Instead of this line

 intent.putExtra(EXTRA_ONLINE_ID, (String) v.getTag());

Try

 intent.putExtra(EXTRA_ONLINE_ID, "" + v.getTag());
Dom