I have a question about intent in android application
i have an array in class1
double [][] tableCityPair = new double[100][100];
---here code to fill array--- in the end of class i want to send tableCityPair to another class, class2.
how i should declare for array in class2 ?
is this right?
Intent it = getIntent();
double tabelJarakAntarKota= it.getDoubleExtra("tableCityPair",3);
The
Bundle
class has methods for passing and retrieving an array ofdouble
s:void putDoubleArray(String, double[])
double [] getDoubleArray(String)
However, these work for one-dimensional arrays. You are attempting to pass a 2D array. I do not know of a direct way to do this. One way to achieve this would be to put N arrays of doubles in a loop.
And at the receiving end, you do:
I'm not sure about the performance implications of this though; since you would be adding 100 extras as part of the bundle.
There could be a better way (perhaps make your pair a
List<List<Double>>
and then implementParcelable
) but I haven't tried any of it so I wouldn't suggest it.and then... make intent it=.... then
then:
THEN in CLASS B