0

When I call activity, I want to pass array as extra so I used below code:

Intent activityIntent = new Intent(getContext(), abc.class);
Bundle bundle = new Bundle();
bundle.putStringArray(EXTRA_MESSAGE_LOCATION, new String[] { "vlaue1" });
activityIntent.putExtras(bundle);
startActivity(activityIntent);

But with this I can pass only one array at time. Can I pass more than one array?

0

1 Answer 1

1
bundle.putStringArray(EXTRA_MESSAGE_LOCATION, new String[] { "vlaue1" });

bundle is like an HashMap. Use a different key :

putStringArray(EXTRA_MESSAGE_LOCATION_2

for instance.

Sign up to request clarification or add additional context in comments.

8 Comments

Thanks for reply, I tried that but that is not work for me. bundle.putStringArray(EXTRA_MESSAGE_LOCATION, new String[] { "value1","value5" }); bundle.putStringArray(EXTRA_MESSAGE_PINTITLE, new String[] { "value2","value3" });
@Deer are you sure you are retriving both with the correct key?
===Call with this=== Bundle bundle = new Bundle(); bundle.putStringArray(EXTRA_MESSAGE_LOCATION, new String[] { "value1","value2" }); bundle.putStringArray(EXTRA_MESSAGE_PINTITLE, new String[] { "value3","value4" }); activityIntent.putExtras(bundle); startActivity(activityIntent); ===retrive with this=== Bundle bundle = this.getIntent().getExtras(); strAryLocation = bundle .getStringArray(MembersAdapter.EXTRA_MESSAGE_LOCATION); strAryPinTitle = bundle .getStringArray(MembersAdapter.EXTRA_MESSAGE_PINTITLE);
what is EXTRA_MESSAGE_LOCATION and EXTRA_MESSAGE_PINTITLE value?
I like you. They are the same string... change it in com.example.myapp.MESSAGE_LOCATION and com.example.myapp.MESSAGE_PINTITLE
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.