My Android notes-my knowledge about android and my Android notes-android

Source: Internet
Author: User

My Android notes-my knowledge about android and my Android notes-android
After coding for such a long time, I recorded some of my concepts about Android. Most of the content below is sourced from network information and official documents. 1. The core of the Android operating system is a branch of Linux. It has typical Linux scheduling and functions. Google modifies and expands Linux to run better on mobile devices, now we see the Android system. 2. Generally, we use Java programming language to compile Android projects. Sometimes we may also use JNI, c/C ++ to achieve functions that other Android frameworks cannot do or are for other purposes. For the JNI part, we use NDK to compile it into a. so dynamic library file, place it in the specified position of the project, and load and call it in the required Java class. After we manually process the JNI part, Android sdks pack the Java code and other data and resources included in the project into a. APK (Android compiler provides a dx tool to convert a Java class file into a dex file. After all, aaptpack all the data in the androidproject into A. APK file), the file can be installed on the Android operating system for running. 3. What we need to know about running apk is: a. The Android operating system is a multi-user Linux system, and each application is a different user. B. By default, the system assigns a unique Linux User ID to each application (this ID is used by the system and cannot be obtained by the application ). The system also sets permissions for all files in the application. Similarly, only the user IDs assigned to the application can access these files. C. Each user (process) has its own virtual machine, so the application code runs in an environment isolated from other applications. D. By default, each application runs in its own Linux Process. Android starts the process when any application component is required, and then closes the process when the process is no longer needed or the system must restore memory for other applications. 4. The virtual machine used in Android is the Dalvik virtual machine, and the ART virtual machine is used after the Android 4.4 system. The difference between ART and Dalvik is that when a Member installs the SDK, the code in the apk is converted into a machine code to improve the running efficiency, which is more efficient than the JIT Dalvik virtual machine.

Android can be implemented in this wayMinimum permission Principle. That is to say, by default, each application can only access the components required to execute its work, rather than other components. In this way, a very secure environment is created, in which the application cannot access the part of the system that it does not obtain permissions.

However, applications can still share data with other applications and access system services through some means: a. Two applications can share the same Linux User ID. In this case, they can access each other's files. To save system resources, you can arrange applications with the same user ID to run in the same Linux Process and share the same VM (the application must also sign with the same certificate); B, applications can request permissions to access device data (such as user contacts, text messages, [SD cards], cameras, and Bluetooth. All application permissions must be granted by the user during installation. When learning Android programming at the beginning, we first came into contact with four major components. They are basic building modules of Android, and each component is a different ele. Me. The system can use it to enter the application. However, not all components are users' actual entry points. Each component exists independently and plays a different role.

Application components are the basic building blocks of Android applications. Each component is a different point through which the system can enter your application. Not all components are users' actual entry points. Some components depend on each other, but each component exists in the form of an independent entity and plays a specific role. Each component is a unique building base block, helps define the overall behavior of an application.

There are four different application component types. Each type serves different purposes and has different lifecycles that define the creation and destruction methods of components.

The following are the four application component types:

Activity ActivityIndicates a single screen with a user interface. For example, an email application may have an Activity that displays a new email list, an Activity used to write an email, and an Activity used to read an email. Although these activities form a cohesive user experience in the email application through collaboration, each Activity exists independently of other activities. Therefore, other applications can start any Activity (if the email application permits ). For example, the camera application can start the Activity in the email application for writing new emails so that users can share images. Service ServiceIt is a component that runs in the background for operations that run for a long time or execute jobs for remote processes. The service does not provide a user interface. For example, when a user is in another application, the Service may play music in the background or obtain data through the network, but does not block the interaction between the user and the Activity. Other components such as Activity can start the service and enable it to run or bind it to facilitate interaction with it. Content ProvidersContent ProvidersManage a group of shared application data. You can store data in a file system, SQLite database, Web, or any other permanent storage location that your application can access. Other applications can query or even modify data through the content provider (if the content provider permits this ). For example, the Android system provides content providers for managing user contact information. Therefore, any application with the appropriate permissions can query a part of the content provider (such ContactsContract.Data) To read and write information about a specific person. The content provider can also read and write private data that is not shared by your applications. For example, the notepad sample application uses the content provider to save notes. Broadcast ReceiverA broadcast receiver is a component used to respond to system range broadcast notifications. Many broadcasts are initiated by the system-for example, broadcast where the notification screen is disabled, the battery is insufficient, or photos have been taken. An application can also initiate a broadcast-for example, notifying other applications that some data has been downloaded to a device and can be used by the application. Although broadcast receivers Do Not Display user interfaces, they can create status notification bar to remind users when a broadcast event occurs. However, broadcast receivers are generally used only as "channels" to other components and are designed to perform a very small amount of work. For example, it may initiate a service to execute a job based on the event. Before the Android system starts an application component, the system must read the "AndroidMainfest. xml" file of the application to check whether the component exists. Most components must be declared in the configuration file. In addition to declaring components, the inventory file has many other functions: 1. Determine any user permissions required by the application. 2. Declare the minimum API level based on the API used by the application. 3. Declare the hardware and software functions used or required by the application, such as camera, Bluetooth, and multi-point touch screen 4. Declare the API library to be connected, such as Google Maps API library 5. Other functions

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.