i am struggling on passing an array from one activity to another. In my MainActivity i build an array similar to this:
Number[] s1 = {1, 8, 5, 2, 7, 4};
The reason i need it in that format, is to graph those points using androidplot in the other activity. Anyways, I send it in this manner:
Intent intent = new Intent(this, DataTable.class);
intent.putExtra("plotpoints", s1);
startActivity(intent);
In my other activity i try to extract my variable
Bundle extras = getIntent().getExtras();
Number[] series1Numbers = extras.getStringArray("plotpoints");
However this gives me an incompatible types error. I know that the problem is in this part of my code:
extras.getStringArray("plotpoints");
but the only functions available for getting arrays are:
getParcelableArray();
getIntegerArrayList();
getParcelableArrayList();
getStringArrayList();
getSparceParcelableArray();
getBooleanArray();
getByteArray();
getCharArray();
getFloatArray();
getShortArray();
getDoubleArray();
getIntArray();
getLongArray();
getStringArray();
getCharSequenceArray();
getCharSequenceArrayList();
I don't see something similar to a getNumberArray();
How am i able to get around this little problem? Appreciate it. :)
The
Number
class implements Serializable. So you should be able to do the following: