1

I am trying to pass 2 double arrays from one activity to the other. However when I try to pass the values from the 2 arrays in the first activity to the arrays in the second activity I get just the values from the first array and its stored in both new arrays.

This is how I use the bundle to send the arrays

Bundle bund = new Bundle();
bund.putDoubleArray(endLatitudeStr, endLatitude);
intent.putExtras(bund);
Bundle bund2 = new Bundle();
bund2.putDoubleArray(endLongitudeStr, endLongitude);
intent.putExtras(bund2);        
startActivity(intent);

And the on the receiving side I have:

Intent intent = getIntent();
mXmlRpcUrl = intent.getStringExtra("XmlRpcUrl");
mSessionID = intent.getStringExtra("SessionID");
mGetSavedTripFunc = intent.getStringExtra("GetSavedTripFunc");
Bundle bund = intent.getExtras();
endLatitude = bund.getDoubleArray(endLatitudeStr);
Bundle bund2 = intent.getExtras();
endLongitude = bund2.getDoubleArray(endLongitudeStr);

However the result is always just the values from the first array(in this case endLatitude) What am i doing wrong?

1
  • Does your endLatitudeStr equals endLongitudeStr? Commented Jan 22, 2014 at 9:19

3 Answers 3

2

Use same bundle object.

Bundle bund = new Bundle();
bund.putDoubleArray(endLatitudeStr, endLatitude);
bund.putDoubleArray(endLongitudeStr, endLongitude);
intent.putExtras(bund);        
startActivity(intent);

Intent intent = getIntent();
mXmlRpcUrl = intent.getStringExtra("XmlRpcUrl");
mSessionID = intent.getStringExtra("SessionID");
mGetSavedTripFunc = intent.getStringExtra("GetSavedTripFunc");
Bundle bund = intent.getExtras();
endLatitude = bund.getDoubleArray(endLatitudeStr);
endLongitude = bund.getDoubleArray(endLongitudeStr);
Sign up to request clarification or add additional context in comments.

8 Comments

Nope it doesnt work still getting just the values of the first array I send :/
So probably the problem is elsewhere can you prove us the endLatitudeStr and endLongitudeStr are different strings
yep they are different strings in each form
Ok. Are you sure you didn't make a typo somewhere in your code between latitude and longitude ? Because the code given here should work. Can you logcat the two arrays before sending and after receiving and showing they are different before and same after.
Bundle[{null=[D@413fa430}]
|
0

If i recall correctly you can only use one bundle because if you make another bundle it will replace the previous bundle so what you need to do is put the bund1 and bun2 on the first bundle then retrieve it use

Bundle bundle = new Bundle();
bundle = getIntent().getExtras();
String mystring=bundle.getString("bund1");
String mystring=bundle.getString("bund2");

Comments

0

Why do you use 2 Bundles? Just use one ...

Bundle bundle = new Bundle();
bundle.putDoubleArray(endLatitudeStr, endLatitude);
bundle.putDoubleArray(endLongitudeStr, endLongitude);
intent.putExtra(bundle);        
startActivity(intent);

and ...

Intent intent = getIntent();
Bundle bundle = intent.getExtras();
endLatitude = bundle.getDoubleArray(endLatitudeStr);
endLongitude = bundle.getDoubleArray(endLongitudeStr);

Comments

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.