Yes this makes sense...I have a question regarding how my app is set up though...I'm using a tabbed interface where each tab launches a new activity. So basically the activity that would launch first sets up the tabs and then starts the activity that is in the first tab...So would I put my splash screen code in the activity that sets up the tabs, or put it in the activity that the user actually sees once the tabs are done setting up?
I'm new to android programming and I've basically built my app from seeing examples of similar things that I want to accomplish in my app. This came about because I got the app running perfectly in the emulator...but when I tested it on two different real devices, it wouldn't load at all on one and it seemed to work ok on the other. It seemed to install correctly on the device that it wouldn't load on, it just never got past the black screen before the first activity starts. And then it would take forever to even try and go back to the device's home screen. So I'm trying to go back and look at my code and see if there is something I could re-work to make it more efficient or something. On Fri, Feb 11, 2011 at 3:06 PM, Kevin Duffey <[email protected]> wrote: > I was going to suggest something similar to what Kostya suggested. As he > said, if you're taking time to load things in an onCreate, first you want to > move it to a thread (AsyncTask). What I do is I've found one of the examples > out there that sets my launcher to the SplashScreenActivity. In my case, I > do it just for showing info about the app, author, etc. So I have a timer > counting down for 15 seconds (which is way too long). If the user touches > the screen at any point, it then times out immediately. Either way, it > starts my main activity at that point. As Kostya said, in your case, once > your background loading stuff is done, start the main activity. This way > they see your splash screen until all the loading is done. You can even make > an animated splash screen to help alleviate the amount of time it seems a > person is waiting. > > > On Fri, Feb 11, 2011 at 11:31 AM, Danielle Murkerson < > [email protected]> wrote: > >> Yes this may be the way to go for me. My main activity has to setup and >> prepare a couple of MediaPlayer objects to play some streaming audio...this >> may take a while on a slow connection and I've seen some examples that use >> the onPostExecute method of an AsyncTask to tell the activity when to stop >> displaying the splash image. >> >> Thanks for the tips...I'll look into this more. >> >> >> On Fri, Feb 11, 2011 at 2:10 PM, Kostya Vasilyev <[email protected]>wrote: >> >>> 11.02.2011 21:53, Danielle Murkerson пишет: >>> >>> Ok...so I would need to use some kind of listener for the between time >>>> of the app loading and starting? I mean I see this all the time on other >>>> apps so I was just wondering how they do this? >>>> >>> >>> The distinction, if any, between loading and starting, is entirely in >>> your code. >>> >>> Android brings your process into memory, creates the main activity, and >>> starts calling its lifecycle methods: onCreate, onStart, onResume, and off >>> you go. >>> >>> If you have a lengthly operation (to load textures in a game, unpack >>> compressed RSS stream, etc.), then you can: >>> >>> 1. have your main activity set its content to a splash image; >>> 2. schedule lengthy operations on a background thread, AsyncTask (or any >>> other way that doesn't tie up the UI); >>> 3. handshake back to the main activity when those lengthy operations are >>> completed, and present the UI for interacting with your application. >>> >>> Item 2 is a good idea anyway, because if you run a lengthy operation in >>> one of the above lifecycle callbacks (onCreate, etc.), and it exceeds the >>> time limit allowed by Android, then the user will see the ANR popup >>> (Application Not Responding - giving the user a choice to kill it or to give >>> it more time). >>> >>> >>> >>>> Usually you click the launcher icon and then an image is displayed for a >>>> short time and then the app starts. I assumed the image is used as a >>>> placeholder while the app finishes loading. >>>> >>> >>> I believe Android just animates a mock-up of the activity, based on what >>> it can gather from the manifest (the color scheme and the title). This >>> happens before onCreate. >>> >>> -- >>> Kostya Vasilyev -- WiFi Manager + pretty widget -- >>> http://kmansoft.wordpress.com >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Android Developers" group. >>> To post to this group, send email to [email protected] >>> To unsubscribe from this group, send email to >>> [email protected] >>> For more options, visit this group at >>> http://groups.google.com/group/android-developers?hl=en >>> >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Android Developers" group. >> To post to this group, send email to [email protected] >> To unsubscribe from this group, send email to >> [email protected] >> For more options, visit this group at >> http://groups.google.com/group/android-developers?hl=en >> > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

