durisvk durisvk - 14 days ago 5x
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());

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?


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)


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