Android settings only the first time the program to display the interface implementation ideas _android

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:
Copy Code code as follows:

<span style= "font-size:18px" ><strong>public void OnCreate ( Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.main);

Preferences = getsharedpreferences ("Count", mode_world_readable);
int count = Preferences.getint ("Count", 0);

//The judge program runs with the first run, and jumps 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);
//Commit modification
Editor.commit ();</strong></span>

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.