Add navigation style to your Android mobile application

Source: Internet
Author: User
Keywords Mobile apps navigation style
Tags activity aliyun an application android android mobile application applications apps

Today's mobile devices are incredibly powerful, much more powerful than many http://www.aliyun.com/zixun/aggregation/7155.html ">" desktop computers that developers use to write their first program. Therefore, it is easy to forget that mobile devices still belong to a limited resource environment. When you develop mobile applications, you must never forget the limitations of the environment in which you run your application. Especially when an application competes with other applications for system resources-some of these applications are more important to the user's day-to-day behavior than your application.

One way to ensure that your application is popular is to ensure that it saves system resources. In Android, the mechanism for using and maintaining system resources is the activity class. The more you understand the lifecycle of this basic class (which is very similar to the Java Servlet), the stronger the ability to adjust the resource usage and performance of the Android mobile application.

We'll start with a quick understanding of the activity class lifecycle. With a series of demo applications, you'll learn how to handle each phase of the Android application lifecycle. After mastering the principles of these methods working together, you can intelligently use system resources. Then update the navigation system for the demo application and use the action icon instead of the menu button to achieve user interaction. Icons are very standard in the mobile application UI, and newer Android devices (version 4.2.2 and higher versions) have deprecated the option menu and instead use the action bar. Mastering how to integrate these features with your Android mobile application will benefit you immensely!

Activity Class Lifecycle

The lifecycle of an activity directly corresponds to the lifecycle of the Android mobile application. When a user interacts with an application or a device running an application, the Android platform performs a callback on the activity instance. When the user launches the application, the initial activity executes a defined lifecycle. When an application goes backstage, it executes a different phase of the lifecycle and executes another phase when the application shuts down. Figure 1 shows the Android activity lifecycle for each interaction phase.


Figure 1. Android Activity Lifecycle

The Android Mobile application lifecycle consists of four phases:

Start pause and resume stop and restart destroy

The following sections describe each phase and its callback methods (which can be implemented within the activity instance).

Initiation in the Activity lifecycle

In the previous article, you have used a callback method that corresponds to the initiating activity, that is, onCreate. You may also be familiar with OnStart and Onresume, and these two methods will be invoked at startup. These methods are now considered in the context of the activity lifecycle.

In the Eclipse Android development environment, choose override/implement Methods ... Option to easily override the method, as shown in Figure 2.

Figure 2. Overriding the activity lifecycle callback method

Next, select the OnStart and Onresume methods:

Figure 3. Select callback

Related Article

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.