Android apps can be written using Kotlin, Java, and C++ languages. The Android SDK tools compile your code along with any data and resource files into an APK or an Android App Bundle. Show
An Android package, which is an archive file with an An Android App Bundle, which is an archive file with an Each Android app lives in its own security sandbox, protected by the following Android security features:
The Android system implements the principle of least privilege. That is, each app, by default, has access only to the components that it requires to do its work and no more. This creates a very secure environment in which an app cannot access parts of the system for which it is not given permission. However, there are ways for an app to share data with other apps and for an app to access system services:
The rest of this document introduces the following concepts:
App componentsApp components are the essential building blocks of an Android app. Each component is an entry point through which the system or a user can enter your app. Some components depend on others. There are four different types of app components:
Each type serves a distinct purpose and has a distinct lifecycle that defines how the component is created and destroyed. The following sections describe the four types of app components. ActivitiesAn activity is the entry point for interacting with the user. It represents a single screen with a user interface. For example, an email app might have one activity that shows a list of new emails, another activity to compose an email, and another activity for reading emails. Although the activities work together to form a cohesive user experience in the email app, each one is independent of the others. As such, a different app can start any one of these activities if the email app allows it. For example, a camera app can start the activity in the email app that composes new mail to allow the user to share a picture. An activity facilitates the following key interactions between system and app:
You implement an activity as a subclass of the There are two types of services that tell the system how to manage an app: started services and bound services. Started services tell the system to keep them running until their work is completed. This could be to sync some data in the background or play music even after the user leaves the app. Syncing data in the background or playing music also represent two different types of started services that modify how the system handles them:
Bound services run because some other app (or the system) has said that it wants to make use of the service. This is basically the service providing an API to another process. The system thus knows there is a dependency between these processes, so if process A is bound to a service in process B, it knows that it needs to keep process B (and its service) running for A. Further, if process A is something the user cares about, then it also knows to treat process B as something the user also cares about. Because of their flexibility (for better or worse), services have turned out to be a really useful building block for all kinds of higher-level system concepts. Live wallpapers, notification listeners, screen savers, input methods, accessibility services, and many other core system features are all built as services that applications implement and the system binds to when they should be running. A service is implemented as a subclass of Note: If your app targets Android 5.0 (API level 21) or later, use the JobService to perform some work based on the event with JobScheduler A broadcast receiver is
implemented as a subclass of ContactsContract.Data , to read and write information about a particular person. It is tempting to think of a content provider as an abstraction on a database, because there is a lot of API and support built in to them for that common case. However, they have a different core purpose from a system-design perspective. To the
system, a content provider is an entry point into an app for publishing named data items, identified by a URI scheme. Thus an app can decide how it wants to map the data it contains to a URI namespace, handing out those URIs to other entities which can in turn use them to access the data. There are a few particular things this allows the system to do in managing an app:
Content providers are also useful for reading and writing data that is private to your app and not shared. A content provider is implemented as a subclass of A unique aspect of the Android system design is that any app can start another app’s component. For example, if you want the user to capture a photo with the device camera, there's probably another app that does that and your app can use it instead of developing an activity to capture a photo yourself. You don't need to incorporate or even link to the code from the camera app. Instead, you can simply start the activity in the camera app that captures a photo. When complete, the photo is even returned to your app so you can use it. To the user, it seems as if the camera is actually a part of your app. When the system starts a component, it starts the process for that app if it's not already running and instantiates the classes needed for the component. For example, if your app starts the activity in the camera app that captures a
photo, that activity runs in the process that belongs to the camera app, not in your app's process. Therefore, unlike apps on most other systems, Android apps don't have a single entry point (there's no Because the system runs each app in a separate process with file permissions that restrict access to other apps, your app cannot directly activate a component from another app. However, the Android system can. To activate a component in another app, deliver a message to the system that specifies your intent to start a particular component. The system then activates the component for you. Activating componentsThree of the four component types—activities, services, and broadcast receivers—are activated by an asynchronous message called an intent. Intents bind individual components to each other at runtime. You can think of them as the messengers that request an action from other components, whether the component belongs to your app or another. An intent is created with an For activities and services, an intent defines the action to perform (for example, to view or send something) and may specify the URI of the data to act on, among other things that the component being
started might need to know. For example, an intent might convey a request for an activity to show an image or to open a web page. In some cases, you can start an activity to receive a result, in which case the activity also returns the result in an For broadcast receivers, the intent simply defines the announcement being broadcast. For example, a broadcast to indicate the device battery is low includes only a known action string that indicates battery is low. Unlike activities, services, and broadcast receivers, content providers are not activated by intents. Rather, they are activated when targeted by a request from a There are separate methods for activating each type of component:
For more information about using intents, see the
Intents and Intent Filters document. The following documents provide more information about activating specific components: Activities, Services, The manifest fileBefore the Android system can start an app component, the system must know that the component exists by reading the app's manifest file, The manifest does a number of things in addition to declaring the app's components, such as the following:
Declaring componentsThe primary task of the manifest is to inform the system about the app's components. For example, a manifest file can declare an activity as follows: <?xml version="1.0" encoding="utf-8"?> <manifest ... > <application android:icon="@drawable/app_icon.png" ... > <activity android:name="com.example.project.ExampleActivity" android:label="@string/example_label" ... > </activity> ... </application> </manifest> In the In the You must declare all app components using the following elements:
Activities, services, and content providers that you include in your source but do not declare in the manifest are not visible to the system and, consequently, can never run. However, broadcast receivers can be either declared in the manifest or created dynamically in code as For more about how to structure the manifest file for your app, see The AndroidManifest.xml File documentation. Declaring component capabilitiesAs discussed above, in Activating components, you can use an
Caution: If you use an intent to start a The system identifies the components that can respond to an intent by comparing the intent received to the intent filters provided in the manifest file of other apps on the device. When you declare an activity in your app's manifest, you can optionally include intent filters that declare the capabilities of the activity so
it can respond to intents from other apps. You can declare an intent filter for your component by adding an For example, if you build an email app with an activity for composing a new email, you can declare an intent filter to respond to "send" intents (in order to send a new email), as shown in the following example: <manifest ... > ... <application ... > <activity android:name="com.example.project.ComposeEmailActivity"> <intent-filter> <action android:name="android.intent.action.SEND" /> <data android:type="*/*" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> </application> </manifest> If another app creates an intent with the For more about creating intent filters, see the Intents and Intent Filters document. Declaring app requirementsThere are a variety of devices powered by Android and not all of them provide the same features and capabilities. To prevent your app from being installed on devices that lack features needed by your app, it's important that you clearly define a profile for the types of devices your app supports by declaring device and software requirements in your manifest file. Most of these declarations are informational only and the system does not read them, but external services such as Google Play do read them in order to provide filtering for users when they search for apps from their device. For example, if your app requires a camera and uses APIs introduced in Android 8.0 (API Level 26), you must declare these requirements. The values for android { ... defaultConfig { ... minSdkVersion 26 targetSdkVersion 29 } } Note: Don't set Declare the camera feature directly in your app's manifest file: <manifest ... > <uses-feature android:name="android.hardware.camera.any" android:required="true" /> ... </manifest> With the declarations shown in these examples, devices that do not have a camera or have an Android version lower than 8.0 cannot install your app from Google Play. However,
you can declare that your app uses the camera, but does not require it. In that case, your app must set the More information about how you can manage your app's compatibility with different devices is provided in the Device Compatibility document. App resourcesAn Android app is composed of more than just code—it requires resources that are separate from the source code, such as images, audio files, and anything relating to the visual presentation of the app. For example, you can define animations, menus, styles, colors, and the layout of activity user interfaces with XML files. Using app resources makes it easy to update various characteristics of your app without modifying code. Providing sets of alternative resources enables you to optimize your app for a variety of device configurations, such as different languages and screen sizes. For every resource that you include in your Android project, the SDK build tools define a unique integer ID, which you can use to reference the resource from your app code or from other resources defined in XML. For
example, if your app contains an image file named One of the most important aspects of providing resources separate from your source code is the ability to provide alternative resources for different device configurations. For example, by defining UI strings in XML, you can
translate the strings into other languages and save those strings in separate files. Then Android applies the appropriate language strings to your UI based on a language qualifier that you append to the resource directory's name (such as Android supports many different qualifiers for your alternative resources. The qualifier is a short string that you include in the name of your resource directories in order to define the device configuration for which those resources should be used. For example, you should create different layouts for your activities, depending on the device's screen orientation and size. When the device screen is in portrait orientation (tall), you might want a layout with buttons to be vertical, but when the screen is in landscape orientation (wide), the buttons could be aligned horizontally. To change the layout depending on the orientation, you can define two different layouts and apply the appropriate qualifier to each layout's directory name. Then, the system automatically applies the appropriate layout depending on the current device orientation. For more about the different kinds of resources you can include in your application and how to create alternative resources for different device configurations, read Providing Resources. To learn more about best practices and designing robust, production-quality apps, see Guide to App Architecture. Additional resourcesIf you like learning with videos and code tutorials, check out the Developing Android Apps with Kotlin Udacity course, or visit other pages in this online guide: Continue reading about:Intents and Intent FiltersHow to use theIntent APIs to activate app components, such as activities and services, and how to make your app components available for use by other apps.ActivitiesHow to create an instance of the Activity class, which provides a distinct screen in your application with a user interface.Providing ResourcesHow Android apps are structured to separate app resources from the app code, including how you can provide
alternative resources for specific device configurations. You might also be interested in:Device CompatibilityHow Android works on different types of devices and an introduction to how you can optimize your app for each device or restrict your app's availability to different devices.System PermissionsHow Android restricts app access to certain APIs with a permission system that requires the user's consent for your app to use those APIs.What is the name of the default view applied to a document upon opening it?The correct answer is Print Layout.
What is a list of the sources used to create a document?A works cited list is a list of sources, usually placed at the end of a document, that you referred to (or "cited") in the document. A works cited list is different from a bibliography, which is a list of sources that you consulted when you created the document.
What is the default view used in Word quizlet?The default (preset) view in Word, which shows the document on a mock sheet of paper in the document window. The default text style in Word. Tap or click VIEW on the ribbon to display the VIEW tab and then remove the check mark from the View Ruler check box.
Is a file format created by Microsoft that shows all elements of a printed document as an electronic image?PDF (Portable Document Format) is a file format that has captured all the elements of a printed document as an electronic image that you can view, navigate, print, or forward to someone else.
|