Android settings are only the first time the program is run to display the interface

Source: Internet
Author: User

First boot after program installation:

Launch page--> feature introduction page--> system Home

Start later:

Start Page--> System home

So it's OK to judge on the launch page.

Can get a file to save a state, recommended with Sharedpreferences.

1. You can define a variable to determine how many times a program is run, and if it is the first time you jump to a guided activity, and if not the first time, perform the system home page.

The system is judged to be the first to run with the following code implementation:

To add code to the activity:

Use Sharedpreferences to record the number of times a program is used

Here's the implementation code:

public void 

onCreate (Bundle savedinstancestate) {  
        super.oncreate (savedinstancestate);  
        Setcontentview (r.layout.main);  
              
        Preferences = Getsharedpreferences ("Count", mode_world_readable);  
        int count = Preferences.getint ("Count", 0);   
              
        Judge the program with the number of runs, if it is the first run will jump to the boot page   
        if (count = = 0) {   
        Intent Intent = new Intent ();  
        Intent.setclass (Getapplicationcontext (), launchguideviewactivity.class);   
        StartActivity (intent);   
        This.finish ();   
        }   
        Editor Editor = Preferences.edit ();   
        Deposit Data    
        Editor.putint ("Count", ++count);   
        Submit modification    
        editor.commit ();

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.