Well, to be honest you don't really need a splash screen.
What is taking so long is that you are loading the images in the same
thread as the UI thread.
This makes it hang while you load your bitmaps.  I'm surprised you're not
getting an application not responding alert.

What I do in my game is load bitmaps in a background thread.
Simply show a progress dialog while the background thread loads the
bitmaps.  Then tell the UI thread that all the resources are ready to go.

Something like:

void onCreate() {
    Handler callbackHandler = new Handler() {
         @Override
         public void handleMessage(Message msg) {
               //all resources have been loaded...
         }
    }

    class MyThread extends Thread {
        Handler handler;
        MyThread(Handler cbHandler) {
            handler = cbHandler;
        }
        @Override
        public void run() {
            //load all the images here...
            handler.sendEmptyMessage();    //let the UI thread know we're
done.
        }
    }

    //show progress dialog here...
    new MyThread(callbackHandler).start();
}

On Sat, Dec 10, 2011 at 11:57 AM, John Goche <johngoch...@googlemail.com>wrote:

>
> At last I was able to find this example...
>
> http://www.wglxy.com/android-tutorials/splash-screen-demo-app-for-android
>
> and code the following, which seems to work for a splash screen with
> AsyncTask:
>
> public class GameActivity extends Activity {
>
>   private Panel panel = null;
>
>   class SplashTask extends AsyncTask<Void, Integer, Void> {
>
>     GameActivity gameActivity;
>
>     SplashTask(GameActivity gameActivity) {
>
>       this.gameActivity = gameActivity;
>
>     }
>
>     @Override
>     protected Void doInBackground(Void... params) {
>
>       Looper.prepare();
>
>       this.gameActivity.panel = new Panel(gameActivity);
>
>       return null;
>
>     }
>
>     @Override
>     protected void onPostExecute(Void params) {
>
>       setContentView(this.gameActivity.panel);
>
>     }
>
>   }
>
>   class Panel extends SurfaceView implements SurfaceHolder.Callback {
>
>     Context context;
>
>     public Panel(Context context) {
>
>       super(context);
>
>       this.context = context;
>
> [...snip...]
>
>
>   @Override
>   public void onCreate(Bundle savedInstanceState) {
>
>     super.onCreate(savedInstanceState);
>
>     setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
>
>     requestWindowFeature(Window.FEATURE_NO_TITLE);
>
>     getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
> WindowManager.LayoutParams.FLAG_FULLSCREEN);
>
>     setVolumeControlStream(AudioManager.STREAM_MUSIC);
>
>     // panel = new Panel(this);
>
>     // setContentView(panel);
>
>     setContentView(R.layout.splash);
>
>     new SplashTask(this).execute();
>
>     PowerManager powerManager = (PowerManager)
> getSystemService(Context.POWER_SERVICE);
>     wakeLock = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, TAG);
>
>     wakeLock.acquire();
>
>   }
>
> And yes, also in my manifest file:
>
>     <activity
>       android:name=".GameActivity"
>       android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
> ...
>
> Thank you for all your kind replies,
>
> As always, feedback welcome,
>
> Regards,
>
>
> 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
>



-- 
~ Jeremiah:9:23-24
Android 2D MMORPG: http://solrpg.com/,
http://www.youtube.com/user/revoltingx

-- 
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