From my understanding of your question, you can load all the data that the second activity requires to display, in the first activity (Splash Activity) and then pass the data or the list of data that first activity has created through POJO classes that implement Serializable
or list of data through Parcellable
. You would not need AsyncTask
in the first activity, since you want the app to remain in that screen as long as it takes to load the data.
You can pass POJO class object from first activity to second activity using Intent
.
- Construct POJO objects using data queried from database.
Pass data from first activity to second using code:
//To pass:
intent.putExtra("MyClass", obj);
// To retrieve object in second Activity
getIntent().getSerializableExtra("MyClass");
Also make sure, each nested class of your main custom class has implemented Serializable interface to avoid any serialization exceptions. For example:
class MainClass implements Serializable {
public MainClass() {}
public static class ChildClass implements Serializable {
public ChildClass() {}
}
}
Reference