When I tried to store the Serializable class AAA in an ArrayList and write it out to a file, I got a NotSerializableException. (Of course, all AAA fields are also Serializable)
The code at that time is as follows. (Please forgive me that the code is that ...)
Navigator.java
public class Navigator {
AppCompatActivity activity;
public void navigateToFuga(ArrayList<AAA> list) {
// FugaActivity.Create Intent in createIntent
//Write hoges to a file and pack the file path into an Intent
activity.startActivity(FugaActivity.createIntent(activity, list));
}
}
HogeActivity.java
public void go() {
navigator.navigateToFuga(new ArrayList<AAA>(){{
add(bbb.aaa);
}});
}
I rewrote the code as follows:
HogeActivity.java
public void go() {
ArrayList<AAA> list = new ArrayList();
list.add(bbb.aaa);
navigator.navigateToFuga(list);
}
It is common to pack data in Intent for screen transition of Activity. The app crashed because I put a large amount of unexpected data in the Intent. So, I temporarily responded by the above method, but I was in trouble with an exception. Looking at the debugger,
FugaActivity.The data type of ArrayList received by createIntent is HogeActivity$It was something like 1, so I thought it was a mistake and corrected it, and it worked.
It took several hours to solve it, so I have to avoid getting caught up in the same problem in the future.
Even if I checked it with NotSerializableException, it seemed that no one was suffering from the same cause, so I wrote it in the article, but I wonder how I should check it. .. ..