Introduction to some concepts in Android Application Development

Source: Internet
Author: User
Tags home screen

Android applications, Window applications, and Web applications are currently the mainstream application development types. In fact, there are many similar design ideas between them, there are also differences. Learning from each other among various technologies helps us understand some design ideas of the Android application development model. Next I will summarize my understanding of some concepts in Android application development.

1. The interface resources are defined by the XML file when the Android Application is developed, which can be separated from the Java source code and automatically stored in the R. java generates an integer ID. This ID can be used in Java source code to control these resources easily. In terms of interface definition, the three applications are similar. The Window application interface also has a special resource file, which can be referenced and modified in the program. The Web application interface is defined in HTML, then, you can operate the DOM tree in Javascript to modify the interface.

2. The ContentProvider encapsulation shields the differences between different underlying data access methods and uses AndroidManifest. xml is registered in the system and provides a unified RESTful URL. The client uses this URL to access data in ContentProvider. The access method is similar to database access, this makes data transmission between applications easy and unified.

3. Intent defines the mechanism for calling another activity in an activity. First, it defines the Intent to specify which activity to call and the operation data carried, then match the Intent with the Intent filter configured for the activity in the xml configuration file. If the Intent matches, the activity is started, and the call service and broadcast are similar.

4. UI development supports code creation or XML definition, which is flexible. Generally, activity views are defined in XML format and data is set in code, you can set the data by defining the adapter and then attaching the adapter to the view.

5. Activities use the layout manager to organize and arrange various views. Many UI systems use things similar to the layout manager to organize UI components.

6. fragments are used to separate activities. Similar to the Framework Window in a Windows application, you can divide several independent areas in the activity. At the same time, because the screen can be converted to a landscape screen, therefore, the layout of fragments in the activity must be different.

7. Because mobile devices support the return button, when starting a new activity or fragment, the old activity or fragment should be saved in a return stack, in this way, when a new activity or fragment exits, the old activity or fragment can be re-displayed. This requirement does not exist for desktop applications and may be similar to the browser's implementation of the Web page Jump back mechanism.

8. The application must be signed and 4-byte aligned before it can be installed on the mobile phone. This prevents others from using other applications to upgrade your application. The activity can set the permission to access public components, you can also set the permissions required to access other activities. Unauthorized access may lead to errors. The activity can also pass the access permissions to another activity through ContentProvider. Security Protection is a feature of Android applications. Such security mechanisms are not defined for Windows and Web applications.

9. AsyncTask submits the task to the background thread pool for execution in the main thread, and creates a Handler in the main thread. When the task is executed in the background, it can send a message to the Handler of the main thread, after listening to messages, Handler triggers some callback functions to be executed in the main thread to update the interface during task processing.

10. The local service can only be called by the same application, while the AIDL service can be called by another application, and complex data can be transferred between the client and the AIDL service through Pracelable, the service usually runs on the main thread. It does not automatically create a subthread. To run a task that has been running for more than 5s, You need to manually create a subthread for execution.

11. A package is usually an application. When two packages use the same user ID, they can access each other's data. A dedicated library project can be created and then included by other projects.

12. The processing program places a message in the main thread queue of the application program. When the subsequent queue processes the message, it can call back and execute the corresponding processing program.

13. The worker thread creates a Handler in the main thread and sends the Handler to the worker thread. The worker thread sends a message to the Hanlder during execution, and the Handler listens to the message and then executes corresponding processing. The difference between AsyncTask and AsyncTask is that AsyncTask is a encapsulated thread pool. Compared with working threads, AsyncTask is more convenient in operating the main thread, because onPreExecute (), onPostExecute () and the onProgressUpdate () method for updating the main thread are all running in the main thread, so there is no need to send messages to Handler for processing.

14. The broadcast receiver uses AndroidManifest. after the xml file is registered to the system (or registered to the system through a program), it can receive and process broadcast messages sent by the client process, it can run independent processes within or outside the client process.

15. The notification first sets the content view, defines an Intent, and then calls the notification manager to send the notification. When a user clicks the notification, the previously defined Intent is called.

16. To run the broadcast receiving program for a long time, a service needs to be started, and a thread is started by the Service. By sending messages to the thread, the thread is driven to process tasks that require a long running time.

17. The home screen is similar to the shortcut on Windows, but the difference is that some display data can be updated regularly, which is a remote view completely separated from the underlying data. It is an Android application. by defining a component receiving program and the associated configuration view, the corresponding configuration view is called when the component receiving program is started for the first time, the configuration view obtains user input information and updates the part view. When the part receiving program is periodically updated by the system, the system obtains the updated data and updates the part view, this allows you to periodically update and display data.

(End)

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.