Android: Load Data in background during splash screen and use it later
android
Solution
i was having the same problem so instead of creating a new activity to show the splash screen i used a Dialog, so you won't need to share the data between the activities. The link i used to do that: http://blog.iangclifton.com/2011/01/01/android-splash-screens-done-right/
Problem
I'm trying to load data from a webserver (getting a JSONArray back) during the start of my application. So far I was able to get the array back only from the main activity with the following commands: ``` if (DEVELOPER_MODE) { StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() .detectDiskReads() .detectDiskWrites() .detectNetwork() .penaltyLog() .build());<br> } jsonArray = JsonParser.getJSONFromURL("cities2.php"); ``` That gave me all the cities (or whatever data i needed) in the current class, but this is not a clean way to do it.. My Problem now is, how to get the cities from my SplashScreen Activity to the Activity where i need the data. My goal is to load all the data from the webserver during the SplashScreen (about 4500 lines of text -> approx. 50KB data) and use them in the different Activities.. So, my main problem at the moment is how to get the data from the webserver that i load during the SplashScreen onto the "last" activity (i.e. SplashScreen -> MainActivity -> SetFilterActivity -> ShowDataActivity (here i need the data) ) I was reading here; Android SplashScreen Here: How to make a splash screen (screen visible when app starts)? Here: http://www.androidpeople.com/android-loading-welcome-splash-spash-screen-example And here: http://www.41post.com/4588/programming/android-coding-a-loading-screen-part-1 And others.... :-) I tried also to write a sperate class that extends Application and "store" the data in there (getters and setters), but somehow it does not work like i want. Can anyone guide me into the right direction on how i can do that a proper way.. Thank you for your help PS: I could easily load the data on each screen whenever i need it, but i want to load it at one point and just use it afterwards in the programm whenever and wherever i need it