Splash Screen : Screen « Hardware « Android

Splash Screen


//Copyright (C) 2011 Enrico Speranza
//This program is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//GNU General Public License for more details.
//You should have received a copy of the GNU General Public License
//along with this program.  If not, see <http://www.gnu.org/licenses/>.

//package it.openalmanac;

import android.app.Activity;
import android.util.Log;
import android.view.KeyEvent;
import android.os.Bundle;
import android.content.Intent;
import android.view.MotionEvent;

public class AlmanacSplash extends Activity {
  /** Called when the activity is first created. */
  protected boolean m_bSplashActive = true;
  protected boolean m_bPaused = false;
  protected long m_dwSplashTime = 2000;

  public void onCreate(Bundle icicle) {

    // Very simple timer thread
    Thread splashTimer = new Thread() {
      public void run() {
        try {
          // Wait loop
          long ms = 0;
          while (m_bSplashActive && (ms < m_dwSplashTime)) {
            Log.d("OpenAlmanac:Debug", "While cicle "+ms);
            // Only advance the timer if we're running.
            if (!m_bPaused)
              ms += 100;
          // Advance to the next screen.
          startActivity(new Intent(
              "Start: com.google.app.splashy.CLEARSPLASH");
        } catch (InterruptedException e) {
          // Thread exception
          // System.out.println(e.toString());
          Log.e("OpenAlmanac:Splash", e.toString());
        } finally {
  //  setContentView(R.layout.splash);

  // If we're stopped, make sure the splash timer stops as well.
  protected void onStop() {

  protected void onPause() {
    m_bPaused = true;

  protected void onResume() {
    m_bPaused = false;

  protected void onDestroy() {
  //When you touch a key, clear the Splash Screen
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    // if we get any key, clear the Splash Screen
    super.onKeyDown(keyCode, event);
    m_bSplashActive = false;
    return true;
  //When you touch the screen, clear the Splash Screen
  public boolean onTouchEvent(MotionEvent event) {
        if (event.getAction() == MotionEvent.ACTION_DOWN) {
          m_bSplashActive = false;
        return true;


Related examples in the same category

1.Multiscreen size
2.Nested PreferenceScreen
3.Get the size of Default Display Screen
4.Screen Orientation
5.Rows have different number of columns and content doesn't fit on screen: column 4 of row 2 shrinks all of the other columns
6.Demonstrates the Tab scrolling when too many tabs are displayed to fit in the screen.
7.Using PreferenceScreen
8.Get the optimal preview size for the given screen size.
9.Methods for converting between the physics world coordinates and the screen coordinates.
10.Get screen Orientation
11.add Home Screen Shortcut
12.Return the supported picture size that best fits on the device screen.
13.Screen Short
14.Set full screen mode