Android Basics, four components

Source: Internet
Author: User

Android applications are written in the Java language. The Android SDK tool compiles all of the data and resource files and code, packaged as an apk file. All the code in an APK file is considered an app, and the Android system device uses this APK file to install the app.

        Once installed on the device, each Android app lives inside its own security sandbox:   ①android OS is a multi-user Linux system, In this case each application is a different user    ② by default, the system assigns an individual user ID to each application, which is only used by the system and is not known to the application. The system sets permission for all files in the app, so only the user ID assigned to the app can access them.    ③ Each process has its own virtual machine, so the code in the app is isolated from the code in other apps.    ④ By default, each app runs in its own Linux process. Android turns on the process when any component in the app needs to be executed, and shuts down when it doesn't need to run or the system needs to allocate memory for other processes.      In this case, the Android system implements the principle of least privilege, which means that each app by default is the one that accesses the components it needs to access. This creates a secure environment in which each app cannot access other parts of the system that it does not have access to.      However, there is a way to share data between apps:   ① has the possibility that two apps share the same Linux user ID, in which case they can access files to other programs. To conserve system resources, apps with shared IDs can run in the same Linux process and share the same virtual machine.    ② an app can initiate request access to get data, such as a user's contacts, short messages, and so on. All application permission must be granted at the time of user installation.      Android Four components:   ①antivities, represents a screen for the interface. An activity needs to inherit the activity class    ②services, a component running in the background, capable of performing long-running operations or performing operations on remote processes. The service has no interface. A service needs to inherit the service class.    ③contentproviders, a contEntprovider manages a set of data that can be shared by an application. We can store the data anywhere that our app can access, such as the file system, the SQLite database, the network, or any other persistent storage place. With ContentProvider, other applications can access and even modify data, provided ContentProvider allows him to do so. ContentProvider is also useful for reading and writing data for private applications. A contentprovider must implement a ContentProvider class, and the application implements a standard set of APIs that enable other programs to execute transactions.    ④broadcastreceivers, is a component of the corresponding system broadcast message. Many broadcasts are generated by the system, such as low battery power, and applications can broadcast, such as letting other application guides have downloaded some data to the device, which can be used. Although broadcast receiver has no interface, they can also generate a status bar alert to inform the user. A broadcast receiver should inherit Broadcastreceiver, and each broadcast is passed through a intent object.  http://blog.csdn.net/llbupt/article/details/7357307

Android Basics, four components (go)

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.