Android learning notes-App Initial Startup interface implementation, android-app

Source: Internet
Author: User

Android learning notes-App Initial Startup interface implementation, android-app

When many apps on android phones start, an image is displayed first. as the beginning of the app, the image is transient. This image usually uses the app icon as an advertisement.

For example:

 


 

 

Its implementation method is very simple. Let's take a test APP as an example to introduce its implementation.

This image actually uses an Activity, which is the AppStart Activity class for the APP.

Source code of this class:

 

/ **
 * Application startup class: display the welcome screen and jump to the main screen
 * @author administrator
 * @version 1.0
 * /
public class AppStart extends Activity {
    
    @Override
    public void onCreate (Bundle savedInstanceState) {
        super.onCreate (savedInstanceState);
        final View view = View.inflate (this, R.layout.start, null);
        setContentView (view);
        
        // Gradient display startup screen
        AlphaAnimation aa = new AlphaAnimation (0.3f, 1.0f);
        aa.setDuration (2000);
        view.startAnimation (aa);
        aa.setAnimationListener (new AnimationListener ()
        {
            @Override
            public void onAnimationEnd (Animation arg0) {
                redirectTo ();
            }
            @Override
            public void onAnimationRepeat (Animation animation) {}
            @Override
            public void onAnimationStart (Animation animation) {}
            
        });
        
        // Compatible with low version cookies (below 1.5, including 1.5.0, 1.5.1)
        AppContext appContext = (AppContext) getApplication ();
        String cookie = appContext.getProperty ("cookie");
        if (StringUtils.isEmpty (cookie)) {
            String cookie_name = appContext.getProperty ("cookie_name");
            String cookie_value = appContext.getProperty ("cookie_value");
            if (! StringUtils.isEmpty (cookie_name) &&! StringUtils.isEmpty (cookie_value)) {
                cookie = cookie_name + "=" + cookie_value;
                appContext.setProperty ("cookie", cookie);
                appContext.removeProperty ("cookie_domain", "cookie_name", "cookie_value", "cookie_version", "cookie_path");
            }
        }
    }
    
    / **
     * redirect to...
     * /
    private void redirectTo () {
        Intent intent = new Intent (this, Main.class);
        startActivity (intent);
        finish ();
    } 

 

After the Activity is started, it will jump to the real application homepage Through animation, that is, the Main Activity class.

 

Reference: https://my.oschina.net/tingzi/blog/77297


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.