I can’t pass a matrix of integers between two activities. here is the code:
-
Activity A:
intent.putExtra("matrix_", (Serializable)matrix); -
Activity B:
Bundle extras = getIntent().getExtras(); matrix = (int[][]) extras.getSerializable("matrix_");
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
When you are creating an object of intent, you can take advantage of following two methods for passing objects between two activities.
putParceble
putSerializable
What you can do with this, is have your class implement either Parcelable or Serializable.
Then you can pass around your custom classes across activities. I have found this very useful.
Here is a small snippet of code I am using
And in newly started activity code will be something like this…
** EDITED WITH LINKS::: **
LINK1 consist of sample code
LINK2
LINK3