durisvk durisvk - 2 months ago 7
Android Question

Passing Double Array through intent passes null

I have the following code:
in TrackerActivity

Intent intent = new Intent(this, SummaryActivity.class);
intent.putExtra(LATITUDES_EXTRA, latitudes.toArray());
intent.putExtra(LONGITUDES_EXTRA, longitudes.toArray());
intent.putExtra(ALTITUDES_EXTRA, altitudes.toArray());
startActivity(intent);


and in SummaryActivity:

latitudes = getIntent().getDoubleArrayExtra(TrackerActivity.LATITUDES_EXTRA);
longitudes = getIntent().getDoubleArrayExtra(TrackerActivity.LONGITUDES_EXTRA);
altitudes = getIntent().getDoubleArrayExtra(TrackerActivity.ALTITUDES_EXTRA);


however I get null for all of them. what could be wrong?

EDIT:

In TrackerActivity the longitudes, latitudes and altitudes are ArrayLists of Double (with capital D). In SummaryActivity they are simple Arrays of double (with small d)

Answer

The Bundle class has methods for passing and retrieving an array of doubles:

 - void putDoubleArray(String, double[])
 - double [] getDoubleArray(String)

may be this ans will help you