Android simple way to implement the splash screen _android

Source: Internet
Author: User
Tags sqlite database

The example of this article describes the Android simple implementation of the splash screen method. Share to everyone for your reference, specific as follows:

Core code:

Package Com.demo.app;
Import android.app.Activity;
Import android.content.Intent;
Import Android.os.Bundle;
Import Android.os.Handler;
public class Splashactivity extends activity {
  private final int splash_display_lenght = 6000;//delay six seconds
  @Override 
   protected void OnCreate (Bundle savedinstancestate) {
    super.oncreate (savedinstancestate);
    Setcontentview (R.layout.splash);
    New Handler (). postdelayed (New Runnable () {public
      void run () {
        Intent mainintent = new Intent ( Splashactivity.this,
            helloworldactivity.class);
        SplashActivity.this.startActivity (mainintent);
        SplashActivity.this.finish ();
      }
    , splash_display_lenght);
  }


Description

Handler (). Postdelayed is deferred for a specified time

The handler class can mainly use the following 3 methods to set the time to execute the Runnable object:

Immediately executes the Runnable object public
Final Boolean post (Runnable R);
Executes the Runnable object public
Final Boolean postattime (Runnable R, Long Uptimemillis) at the specified time (uptimemillis);
Executes the Runnable object public
Final Boolean postdelayed (Runnable R, Long Delaymillis) at the specified time interval (delaymillis);

The following two lines of code start a new activity and close the current activity.

SplashActivity.this.startActivity (mainintent);
SplashActivity.this.finish ();

For more information on Android-related content readers can view the site: "The activity of Android programming skills Summary", "Android Resources Operating Skills Summary", "Android File Operating skills summary", " Android Operation SQLite Database skills Summary, "Android operation JSON format Data Skills summary", "Android Database Operation skills Summary", "Android programming development of SD card Operation Summary", "Android Development introduction and Advanced Course", The Android View view tips summary and the Android Control usage summary

I hope this article will help you with the Android program.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.