Android Settings Launcher screen

Source: Internet
Author: User
Tags time in milliseconds

The meaning of the start-up interface is to make the background processing time-consuming complex work, when the work is done, you can enter the main interface. Using a single image as the starting background is a better experience than letting the user wait for the layout to load.

First, you need to create a simple layout:

<?XML version= "1.0" encoding= "Utf-8"?><LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"Android:background= "@drawable/launch"android:orientation= "vertical"></LinearLayout>

Here I will directly set the background of the entire layout as a picture, so that it can adapt to the size of the screen.

Then, create a launchactivity, register it in Androidmanifest, and let it start first:

 Public classLaunchactivityextendsActivity {@Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); //Load Startup pictureSetcontentview (R.layout.activity_launch); //background processing time-consuming tasks        NewThread (NewRunnable () {@Override Public voidrun () {//time consuming tasks, such as loading network dataRunonuithread (NewRunnable () {@Override Public voidrun () {//Jump to MainactivityIntent Intent =NewIntent (launchactivity. This, Mainactivity.class);                        StartActivity (Intent); //End the current ActivityLaunchactivity. This. Finish ();            }                });    }}). Start (); }}

This way, once the background task has finished processing, it will automatically go to the main interface of the software.

Of course, there is also a timer to start the main interface, usually for ad serving.

 Public classLaunchactivityextendsActivity {@Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); //Loading the Startup interfaceSetcontentview (R.layout.activity_launch); Integer Time= 2000;//set the wait time in millisecondsHandler Handler =NewHandler (); //when the timing is over, jump to the main screenHandler.postdelayed (NewRunnable () {@Override Public voidrun () {startactivity (NewIntent (launchactivity. This, Mainactivity.class)); Launchactivity. This. Finish ();    }}, time); }}

Android Settings Launcher screen

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.