Android (1)--application and activity

Source: Internet
Author: User
Tags time and date home screen


One. Android App type:

(1) Foreground application-need to consider activity life cycle

Can only run in the foreground app, when he is not visible will be suspended, for example: Game application;

(2) Background applications--service and broadcastreceiver are drivers of background applications

An application with a very limited interaction, unless during the configuration, the other life periods are hidden, for example: alarms;

(3) Intermittent application--activity, service and broadcastreceiver, and notification joint use

Updates the UI when the app is visible, and sends notifications (or other means) to inform the user when the app is not visible;

(4) Widgets and Live Wallpaper:

Can create some interactive visible components, located in the user Home screen, widgets are mainly used to display dynamic information, such as: weather, battery power, time and date;


Two. Components of Android Apps

Describe the components:

1.activity--implements UI, uses view or fragment to layout and display information, and responds to user actions;

2.service--is not visible, can update the data source and activity, can trigger the pass and broadcast intent;

3.contentprovider--A shareable persistent data memory. He is the first choice for sharing data between applications, you can configure the CP of your application to be available to other applications, or you can use the cp,android provided by other apps to provide CP locally, for example: contact information, Media Library information, etc.;

4.intent--a powerful messaging framework between applications. You can also start/stop activity, Service. You can also broadcast messages;

5.broadcastreceiver--intent Listener. can automatically start the application in response to a received intent, more for the event-driven application;

6.widget--is a special variant of broadcastreceiver;

7.Notification


Three. Activity of Android

    1. activity+ layout + View +fragment = UI;

    2. Activity stack

(1) The status of each activity is determined by its position in the activity stack;

(2) when the Android memory manager decides which application to release the resource, it also determines the priority of the activity through the activity stack and decides which application to terminate;

(3) The activity stack is the current set of all running activity LIFO;

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/79/F3/wKioL1afIofAi2U2AAEXbaoYQUM686.png "title=" em_ 2016120135921.png "alt=" Wkiol1afiofai2u2aaexbaoyqum686.png "/>

3.Activity status

(1) Activity status--at the top of the stack, visible, with focus, can accept user input;

Android will keep his activity at all costs and destroy the lower activity as necessary to free up resources for its use;

When another activity is active, he will be in a paused state;

(2) Suspend status--visible in general, but no focus, can not receive user input events;

In extreme cases, the system will be destroyed to release resources;

When he is completely invisible, it is in a stopped state;

(3) Stop state--can not be seen;

is still in memory and retains state information, but when the system needs to free up memory, they are the preferred object;

Saving UI and data information is important when activity is in a paused/stopped state;

(4) Termination status-activity that is exited or closed, removed from the stack;


4.Activity Lifetime and Status monitoring

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/79/F3/wKioL1afH-STmzhNAAE_rvl7KBM352.png "title=" em_ 201612013463.png "alt=" Wkiol1afh-stmzhnaae_rvl7kbm352.png "/>

Android (1)--application and activity

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.