Getting Started with Android

Source: Internet
Author: User

Learn to get started with Android.

Activity: A window that contains the user interface of the application. The goal is to interact with the user.

Intent: "Glue" that is able to seamlessly connect different activities from different applications to work together to ensure that these tasks execute as if they belong to a single application.

Fragmentation: A micro-activity that adapts to the size and direction of the screen, fragments can be seen as another form of activity, and fragments are always embedded in the activity.

The activity base class defines a sequence of events for an active life cycle.

OnStart () Called when the activity is visible to the user.

Onresume () Called when the activity starts interacting with the user.

OnPause () is called when the current activity is paused and the previous activity is resumed.

OnStop () Called when the activity is no longer visible to the user.

OnDestroy () is called before the activity is destroyed by the system (either manually or by the system to save memory).

Onrestart () is called when the activity has stopped and wants to start again.

When an activity starts, the OnStart () and Onresume () events are always called, regardless of whether the activity is resumed from the background or is newly created. The OnCreate () method is called when the activity is first created.

Android Modified style:

The main modification of the Androidmanifest.xml file in the <Activity> element adds the Android:theme property.

WindowManager to get whether the device is currently in portrait or landscape mode.

To add fragmentation to an activity, you can use the Fragmentmanager class to perform (add, delete, or replace) fragments.

The life cycle of a fragment:

Fragment creation:

Onattach ()

OnCreate ()

Oncreateview ()

Onactivitycreated ()

Fragmentation can be seen through state:

OnStart ()

Onresume ()

When a fragment enters background mode, it experiences the following States:

OnPause ()

OnStop ()

When the fragment is destroyed (its current activity is destroyed), it experiences the following States:

OnPause ()

OnStop ()

Ondestroyview ()

OnDestroy ()

Ondetach ()

The state in which the fragment is saved in the Onsaveinstancestate () method.

The main difference between activity and fragmentation: When an activity enters the background, it is placed in the back stack and the activity can be resumed when the user presses the return button. However, fragments are not automatically placed into the back stack when they are in the background. To do this, you need to display the call Addtobackstack () method during fragment processing.

Getting Started with Android

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.