Android Study Notes (1)

Source: Internet
Author: User

Android Study Notes (1)

AndroidManifest. xml file And Differences and usage

1. It is an officially defined permission. It is the permission that needs to be declared when someone else's things are called. The permission defined by the user is the permission that someone else needs to declare when calling this program. Therefore, you generally do not need to declare a permission for your application, unless you provide code or data for other applications to call. Label.

2. And The two are declared at the same level as the node, Is applied to the entire application, and Only apply to various components inside the application, such, , And so on.

Usage example

Declare your permissions on the same node , You can use this permission in one of the following:

Android: permission = "com. notfatboy. project. VIEW_MYDATA"

...

Of course, you still need to use To declare the application requires this permission so that the application can work normally. As follows:

The syntax format is as follows:

Android: icon = "drawableresource"

Android: label = "string resource"

Android: name = "string"

Android: permissionGroup = "string"

Android: protectionLevel = ["normal" | "dangerous" | "signature" | "signatureOrSystem"]/>

Android: name indicates the permission name. androidLprotectionLevel must be declared to inform the System of the application's permission requirements. permissionGroup is optional, it is used to help the system display permissions to users, with few customization options. It is best to use defined ones to make it easier to use.

Android hardware-accelerated hardwareAccelerated

Since Android 3.0 (API level 11), Android 2D display pipelines are designed to support Hard acceleration. Hard acceleration uses GPU to perform all the rendering operations on the View canvas. The easiest way to enable Hard acceleration is to enable hardware acceleration for the entire application. If your application only uses standard view and Drawable, enabling Hard acceleration globally will not have any negative impact. However, Hard acceleration is not supported by all 2D plotting, so enabling it may affect custom plotting. The problems that occur are often invisible, which may be exceptions or incorrectly displaying pixels. To avoid these problems, Android allows ,, , Enable the Hard acceleration feature. Add the property android: hardwareAccelerated = "true ".

Window-level control is more granular than application and activity-level control. Use the following method to enable Hard acceleration for a window:

GetWindow (). setFlags (WindowManager. LayoutParams. FLAG_HARDWARE_ACCELERATED,

WindowManager. LayoutParams. FLAG_HARDWARE_ACCELERATED );

However, Hard acceleration cannot be disabled at the window level.

View-level control is more granular than application, activity, and window-level control. You can use the following code to disable Hard acceleration for individual views during running: myView. setLayerType (View. LAYER_TYPE_SOFTWARE, null), but hardware acceleration cannot be enabled at the view level.

How to determine whether a View is hard-accelerated: Sometimes it is very useful for an application to know whether hardware acceleration is enabled, especially for custom views and other things. This is even more important when some custom drawings are not supported by the latest pipelines in the application. There are two ways to check whether the application is hard-accelerated: View. isHardwareAccelerated (): returns true if the View is attached to a hard-accelerated window; Canvas. isHardwareAccelerated (): returns true if the Canvas is hard-accelerated. If you have to do this in your drawing code, you should use Canvas. isHardwareAccelerated () instead of View. isHardwareAccelerated (). When a view is attached to a hard-accelerated window, it can still be drawn using a Canvas without any hardware speed. For example, when a view is drawn to a bitmap for high-speed cache.

Android: configChanges attributes

Android: The configChanges attribute is used in the element to control whether to re-call each declaration cycle when switching between landscape and landscape screens. The value "orientation | screenSize" indicates that the Activity can be reloaded when the program is running. The value "orientation" indicates that each lifecycle will be called again when the screen is switched, the function is executed only once when the horizontal and vertical screens are switched. If the android: configChanges attribute is not set, the function re-calls the life cycle and performs the function once when the horizontal screen is switched, this operation is performed twice when the portrait screen is switched.

Android: screenOrientation attributes

This attribute is used to restrict switching between landscape and landscape screens. If the attribute value is "portrait", only landscape screens are displayed on the page. If the attribute value is "landscape", only landscape screens are displayed on the page.

Android: launchMode attributes

LaunchMode plays an important role in the jump process of multiple activities. It can decide whether to generate a new Activity instance and whether to reuse an existing Activity instance, whether to share a task with other Activity instances. Here is a brief introduction to the concept of a task. A task is an object with a stack structure. A task can manage multiple activities. When an application is started, a corresponding task is created.

Activity has four types of launchMode: standard, singleTop, singleTask, and singleInstance. The android: launchMode attribute configured in AndroidManifest. xml is one of the preceding four types. The following describes four values:

1. standard: The standard mode is the default start mode. No matter whether there are any existing Activity instances in the task, when the Activity instance is loaded, the system will generate a new instance and place it on the top of the task stack.

2. singleTop: jump from Activity1 to Activity2, and then from Activity2 to Activity1. If the task stack is at the top of Activity1, no new instance is created and the instance is directly used; if the instance at the top of the stack is not Activity1, you need to create a new instance of activity1.

3. singleTask: jump from Activity1 to Activity2, and then from Activity2 to Activity1. As long as the Activity1 instance in the task stack is at the top of the stack or at the bottom of the stack, no new Activity1 instance will be created, instead, the existing Activity1 instance is used directly.

4. singleInstance: a global Activity has only one corresponding instance, even called in different apk.

Android: windowSoftInputMode attribute

Defines the interaction mode between the activity main window and the soft keyboard, which can be used to avoid the problem of the Input Method panel occlusion. A new feature added after Android1.5. This attribute can affect two things:

1. When a focus is generated, whether the keyboard is hidden or displayed

2. Whether to reduce the size of the active main window to free up space for storage of the soft keyboard,

It must be set to a value in the following list or a "state ..." Add "adjust ..." Value combination. Set multiple values in any group-multiple "states ..." Values. For example, & mdash has undefined results. Use | to separate values. For example, the value set here will overwrite the value set in the topic.

Meanings of values:

StateUnspecified: the soft keyboard status is not specified. The system selects an appropriate status or depends on the topic settings.

StateUnchanged: When this activity appears, the soft keyboard will remain in the status of the previous activity, whether hidden or displayed

StateHidden: When you select activity, the keyboard is always hidden.

StateAlwaysHidden: when the Activity Main Window gets the focus, the keyboard is always hidden.

StateVisible: the soft keyboard is usually visible

StateAlwaysVisible: the Status displayed on the keyboard when the activity is selected

AdjustUnspecified: the default setting. It is usually determined by the system whether to hide or display it.

AdjustResize: This Activity always adjusts the screen size to reserve space for the soft keyboard.

AdjustPan: the content of the current window will be automatically moved so that the current focus is never overwritten by the keyboard and the user can always see the part of the input content.

Android: exported attributes

This attribute indicates whether the service can be called or interacted with by other application components. If it is set to true, it can be called or interacted. Otherwise, it cannot. If it is set to false, only components of the same application or applications with the same user ID can start or bind the service. Its default value depends on the filter contained in the service. Without a filter, the service can only be called by specifying a specific class name. This means that the service can only be used within the application (because other external users do not know the class name of the Service ), therefore, the default value of this attribute is false. On the other hand, if at least one filter is included, it means that the service can provide services to other external applications, so the default value is true. This attribute is not the only method that limits the exposure of services to other applications. You can also use permissions to restrict external entities that can interact with the service.

Android: authorities attributes

Indicates the content provider. The value is the name of the package where the provider is located + the provider itself. For example, android: authorities = "com. bbk. VoiceAssistant. provider"

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.