> On Wed, Dec 7, 2011 at 10:18 PM, rich friedel <rich.frie...@gmail.com>wrote:
>
> Yeah, create an 
> AsyncTask<http://developer.android.com/reference/android/os/AsyncTask.html>and
>  do your loading/building stuff in that.
> You can even post a "message" back for the dialog in the
onProgressUpdate()<http://developer.android.com/reference/android/os/AsyncTask.html#onProgressUpdate%28Progress...%29>
.
> When it is done 
> onPostExecute()<http://developer.android.com/reference/android/os/AsyncTask.html#onPostExecute%28Result%29>will
>  be called where you can call your startActivity(Intent).
> I will warn you though, use due diligence when implementing AsyncTask:
>
https://www.google.com/#hl=en&q=android+development+asynctask+crash+when+rotating+screen
> if you destroy the activity that the AsyncTask is tied to then recreate
it (as in a screen rotation) the
> AsyncTask won't know what to do and throw an exception.

Hello all,

Sorry for bringing up this topic again but I haven't figured out how to do
it (yet).
As mentioned I am trying to make a splash screen for an application. The
reason
I need the splash screen is my app is taking a long time to load. I want
the splash
screen to be displayed until the images and sounds are finished loading,
and when
the main menu is ready to be displayed I want the splash screen to go that
very moment
without any further delays. So, I am not sure what way to go with all this
information to
digest and not so sure which path to take or how each path works. Perhaps
someone
could give me some help in understanding the best solution for my use case
and why it works?

Thanks a lot,

John Goche

(here is what I've found so far...)

----------------------------------------------------------------------------------

http://stackoverflow.com/questions/3536590/android-splash-screen-loading-screen

I've had a look at this example but it seems it just waits three seconds
and then ditches the splash screen for the main application. In my case
different phones will take different amount of time which I do not know.
Basically I need to display the splash screen while the images and sounds
load up. When done I need to display my application.

http://www.androidpeople.com/android-loading-welcome-splash-spash-screen-example

----------------------------------------------------------------------------------

Then I found this post stating that an AsyncTask can be used:

http://stackoverflow.com/questions/1596947/android-application-loading-screen

http://developer.android.com/reference/android/os/AsyncTask.html

----------------------------------------------------------------------------------

Then I found the code at:

http://www.barebonescoder.com/2010/04/a-simple-android-splash-screen/

public class SplashScreen extends Activity {
   /** Called when the activity is first created. */
   @Override
   public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.splash);
      Thread splashThread = new Thread() {
         @Override
         public void run() {
            try {
               int waited = 0;
               while (waited < 5000) {
                  sleep(100);
                  waited += 100;
               }
            } catch (InterruptedException e) {
               // do nothing
            } finally {
               finish();
               Intent i = new Intent();
               i.setClassName("com.testing.splashscreensample",
                              "com.testing.splashscreensample.mainmenu");
               startActivity(i);
            }
         }
      };
      splashThread.start();
   }
}

but I am not clear on what the code exactly does. Where does the
InterruptedException
arise from? What happens if it takes more than 5 seconds to load the
screen? In that
case finish() will be called and there will be a blank screen while the
game menu
screen loads? Can someone please explain to me the details of this code? Is
an
AsynchTask better?

Then there is this post:

http://stackoverflow.com/questions/1979524/android-splashscreen

Is using an AsyncTask better? What is the purpose of the template parameters
<String, Void, Object> in the AsyncTask?

Then there is this site:
http://jyro.blogspot.com/2009/11/android-asynctask-template.html

and this site:
http://android-developers.blogspot.com/2009/05/painless-threading.html

I'm somewhat confused... not sure if someone
on this list would be so kind so as to help me out
in understanding the different elements involved in
setting up an AsyncTask or any other good way to
set up a postponment till stuff is loaded,

Thanks again,

John Goche

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to