Introduction to the basic components of the android-Android Application (5): four main components of android

Source: Internet
Author: User

Introduction to the basic components of the android-Android Application (5): four main components of android
Activity

  • Activity is the most basic module. We become an activity. An activity is usually a single screen. Every activity is implemented as an independent class and inherits the base class of the activity. Display the user's view in the implementation class of the activity and process the event.
  • Intent implements direct switching between activity and activity. Intent class is used to describe the functions of an application. It has two important parts: data corresponding to actions. Typical action types include MAIN and VIEW.

If you want the activity to display the specified view, you only need to call the setContentView of the Activity.

The following code is used:

// Load the layout file activity_main.xml
SetContentView (R. layout. activity_main );

Service

The Service and Activity position are parallel, and it also represents an independent Android component. The difference between the Service and Activity is that the Activity is at the front end, there is user interaction, and the Service is running in the background, without user interaction, there is no graphical user interface.

BroadCastReceiver

Broadcast recipient

Your application can use it to filter external events and only receive and respond to external events that interest you (for example, when calls are made, or when data networks are available. The broadcast receiver has no user interface. However, they can start an activity or serice to respond to the information they receive, or use icationicationmanager to notify users. Notifications can be used in many ways to attract users' attention-flashing back lights, vibrations, and playing sounds. In general, a persistent icon is placed on the status bar. You can open it and get the message.

ContentProvider

The android platform provides Content Provider to provide a specified dataset of an application to other applications. The data can be stored in a file system, in an SQLite database, or in any other reasonable way. Other applications can obtain or store data from the content provider through the ContentResolver class. (equivalent to outsourcing a shell in an application), the content provider is required only when data is shared among multiple applications. For example, the address book data is used by multiple applications and must be stored in a content provider.

Signature Android Program

Android applications can be installed on Android systems only after being digitally signed by the developer's self-signed certificate. When we run the project, the ADT auxiliary tool signs the apk file and uses the default Debug version of the signature file.

The signature file is the identifier of the developer's identity. Only when both the package name and signature file are the same can we upgrade the original application.

We can use Eclipse to generate a signature file for us.

Right-click the project FristAndroid and choose Android Tools-Export Signed Application Package...

Click next in the pop-up dialog box.

In the next window, select create new keystore. You need to select the storage path of the digital signature file and set the file name. And set the password for the signature file (if you already have a signature file, you can select use existig keystore)

Next, click next to bring up a new window asking us to set the alias, signature file validity period, and user name

After entering the information, continue to next. You will be asked to select the path for storing the packaged apk file. Click the browse button on the right to select the path.

After selecting the path, we have completed the packaging settings. Click finish. After a while, the apk file will appear in the place you specified

Note:After the signature file is successfully created for the first time, the console will output some information

Please save the MD5 and SHA1 values and use them later. If you forget to save them, you can use the command to output the information.

 

The preceding four steps are used to create a new digital certificate. Once the certificate is created, the package can be directly used.

To use an existing signature file for packaging, follow these steps:

Right-click the project FristAndroid and choose Android Tools-Export Signed Application Package...

Then select the project to be packaged

In the displayed dialog box, select Use existing keystore.

The following steps are the same as above.

 

OK. So far, we have focused on setting up and using the Android development platform, including downloading and installing the SDK and ADT. In addition, we also introduced the setup of FirstAndroid, the first Android Application, and analyzed the Android structure. Next we will introduce the android Application Interface Programming..

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


How to Use Android components to develop applications on Android phones

Android phones are a real simulator. To develop android apps, You need to link to eclipse and build a development environment. android has four components: Activity, Service, Broadcast explorer, and Content Provider, if you have not learned it, you cannot develop it.

An Android instance code, which is used by four Android components. Thank you very much.

How does the Android3.2 simulator client connect to the pc server through socket ?? Urgent: I have recently written the same program on the simulator. I can send it to you. Please refer to it: If you have any questions, please try again ..

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.