Simple splash screen

Basic Tutorials concerning: GUI, Views, Activites, XML, Layouts, Intents, ...

Re: Simple splash screen

Postby vivianaranha » Mon Jan 18, 2010 6:53 pm

Is there a way we can add sound - like a short sound when teh splash screen appears
vivianaranha
Once Poster
Once Poster
 
Posts: 1
Joined: Mon Jan 18, 2010 6:50 pm

Top

Re: Simple splash screen

Postby sampath_sl » Sat Oct 09, 2010 7:40 am

Many thanks to PlusMinus and a.vogel for the tutorials.

I have a specific scenario which I'm stuck for a few days now.

My Android app requires loading a relatively large data set when its invoking. So I added a splash screen (using the instructions in the tutorials) and the splash screen is working fine. Now I want to load the data-set in the background while the splash screen is displayed.

Any strategy for achieving this?

Thank you.
sampath_sl
Developer
Developer
 
Posts: 35
Joined: Sun Apr 11, 2010 4:45 pm
Location: Colombo

Re:

Postby Schermvlieger » Thu Nov 18, 2010 2:51 pm

jpe30 wrote:I'm having the same problem as ashy, the setVisibility(View.GONE) line throws a null pointer exception. I need this as I need to show 2 splash screens, one right after the other.

Any suggestions as to how to get this working?



Calling any method on the view is causing a nullpointerexception. Maybe it would be better if tutorials with source code are tested thoroughly to make sure they work, as this causes unneeded frustration. Also, it's not very encouraging to see that no help was provided after 18 months...
Schermvlieger
Senior Developer
Senior Developer
 
Posts: 159
Joined: Fri Feb 26, 2010 1:37 pm

Re: Simple splash screen

Postby lub997 » Wed Jan 26, 2011 12:12 pm

I am new to Android programming and I got the example code at the beginning of this thread to compile fine in Eclipse without any errors, but I don't understand how to connect the example code to my existing program and make it functional. I added it to my existing program's package in Eclipse, but how do I actually call the example splashscreen code and make it function from my existing program that I am trying to add it to? Maybe this is a silly question, but I am new to Android and can't seem to figure it out. In my existing code, I have:

Code: Select all
package com.helloworld;

import android.app.Activity;
import android.os.Bundle;

public class HelloWorld extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}


I have the example code very slightly modified in splashscreen.java

Code: Select all
package com.helloworld;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.ImageView;

public class splashscreen extends Activity {
   
   private static final int STOPSPLASH = 0;
   //time in milliseconds
   private static final long SPLASHTIME = 5000;
   
   private ImageView splashscreen;
   
   //handler for splash screen
   private Handler splashscreenHandler = new Handler() {
      /* (non-Javadoc)
       * @see android.os.Handler#handleMessage(android.os.Message)
       */
      @Override
      public void handleMessage(Message msg) {
         switch (msg.what) {
         case STOPSPLASH:
            //remove SplashScreen from view
            splashscreen.setVisibility(View.GONE);
            break;
         }
         super.handleMessage(msg);
      }
   };
   
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.main);
         splashscreen = (ImageView) findViewById(R.id.splashscreen);
         Message msg = new Message();
         msg.what = STOPSPLASH;
         splashscreenHandler.sendMessageDelayed(msg, SPLASHTIME);
    }
}


All compiles fine, but when the program is run the splashscreen never shows up because it is never called and I don't know how to call it. Where / how do I call the splashscreen code from my existing code? Thanks for any assistance that anyone might have.
lub997
Once Poster
Once Poster
 
Posts: 1
Joined: Wed Jan 26, 2011 11:59 am

Top
Previous

Return to Novice Tutorials

Who is online

Users browsing this forum: No registered users and 6 guests