Android Implementation App Welcome page simple production idea _android

Source: Internet
Author: User

Now the app will generally have a welcome interface when the application starts, this kind of welcome interface usually has two kinds of situations, one is used to detect the network state in the background when the application starts, or load the network data and so on some time-consuming operation, for instance QQ, micro-letter. There is also a way to start their own brand logo, generally for the logo, such as Taobao. Today I'm going to do both of these effects by simply coding.

1, in the background load network data, run some time-consuming tasks, the code is as follows:
Welcomeactivity.java File Code

public class Welcomeactivity extends activity {

  @Override
  protected void onCreate (Bundle savedinstancestate) { C3/>super.oncreate (savedinstancestate);
    Requestwindowfeature (window.feature_no_title);
    Setcontentview (r.layout.activity_welcome);

    New Thread (New Runnable () {
      @Override public
      void Run () {
        //Here runs the time-consuming task
        Runonuithread (New Runnable () c11/> @Override public
          void Run () {
            Intent Intent = new Intent (welcomeactivity.this, mainactivity.class);
            StartActivity (intent);
            WelcomeActivity.this.finish ();}})
    . Start ();
  }

This will automatically disappear after the data load ends.

2, the page will stay fixed time

The Welcomeactivity.java file code is as follows:

public class Welcomeactivity extends activity {

  @Override
  protected void onCreate (Bundle savedinstancestate) { C3/>super.oncreate (savedinstancestate);
    Requestwindowfeature (window.feature_no_title);
    Setcontentview (r.layout.activity_welcome);
    Handler Handler = new Handler ();
    When the timer is over, jump to the main interface
    handler.postdelayed (new Runnable () {
      @Override public
      void Run () {
        Intent Intent = New Intent (Welcomeactivity.this, mainactivity.class);
        StartActivity (intent);
        WelcomeActivity.this.finish ();
      }
    , 3000);
  }

The feature of this approach is that the Welcome page will stay at a fixed time, suitable for placing ads or branding icons.
Finally, don't forget to modify the startup page in the Androidmanifest.xml file.

<activity android:name= ". Welcomeactivity ">
      <intent-filter>
        <action android:name=" Android.intent.action.MAIN "/>

        <category android:name= "Android.intent.category.LAUNCHER"/>
      </intent-filter>
    </ Activity>

OK, the above is simply welcome to the production of the page ideas.

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

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.