1. Summary of Android Manifest tag highlights
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.base.module.recorder"
android:versionCode="1"
android:versionName="1.0"
android:sharedUserId="android.uid.system"
android:installLocation="auto|internalOnly|preferExternal"
>
The manifest tag package is the project package attribute, the version code is the version integer, the number increases with each iteration, and the version Name is the common version number displayed to the user.
1.1 Introduction to Common Labels
installLocation
Property specifies whether the application is allowed (or preferred) to be installed in external memory (SD card) rather than internal memory. PreerExternal prefers to install applications into external memory, while auto requires system decision.
Note: The following programs are not suitable for installation into external storage: applications with Widget, Live Wallpaper and Live Folder; applications providing uninterrupted services; input method engines; Device Admin Receiver and its management capabilities will be disabled.uses-sdk
The node is used to define the minimum and maximum SDK versions that must be available on the device to run the application correctly, as well as the target SDK designed for the application, which are set by the minSDK Version, maxSDK Version and targetSDK Version attributes, respectively.
Target SDK Version is usually specified as the highest SDK version in development.
Normally it is not necessary to specify the maximum SDK version.
<uses-sdk
android:minSdkVersion="17"
android:targetSdkVersion="27" />
uses-configuration
You can specify the combination of each input mechanism supported by the application, which is generally not required, but is useful for games with special input control.uses-feature
Specify each hardware function required by the application. This avoids installing applications to devices that do not contain the necessary hardware functions, such as NFC hardware.
<uses-feature android:name="android.hardware.nfc" android:required="false"/>
required attributes can cover implied hardware requirements.
<uses-feature android:glEsVersion="0x00010001"/>
Specify the lowest version of OpenGL, with 16 bits high representing the main version number and 16 bits low representing the minor version number.
- supports-screens
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:largestWidthLimitDp="720"
android:compatibleWidthLimitDp="600"
android:requiresSmallestWidthDp="480"
android:anyDensity="true"
android:smallScreens="false"
android:xlargeScreens="false"
android:resizeable="true">
supports-gl-texture
Used to declare that the application can provide texture resources compressed in a specific GL texture compression format.uses-permission, as part of the security model, declares the application needs.
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
- permission application components can create permissions to restrict access to shared application components.
<permission android:name="com.test.MYTEST"
android:protectionLevel="dangerous"
android:description="xx"
android:label="xx"/>
The level of access rights includes (normal | dangerous | signature | signatureOrSystem)
- instrumentation
<instrumentation
android:label="xx"
android:name="xx"
android:targetPackage="xx"/>
- application
A Manifest can only contain one application node. Use various attributes to specify the various data (headings, icons, and topics) of the application. When developing, you should include a debuggable property set to true to enable debugging, which is disabled at publication time.
<application
android:name="com.base.module.recorder.RecorderApplication"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:debuggable="true">
activity
Each activity requires an activity tag that allows the use of intent-filter tags to define the Intent used to start the activity.Service
With Activity.Provider specifies each Content Provider in the application. Used to manage database access and sharing.
- Reciver registers a Broadcast Receiver, allowing the use of intent-filter tags to define Intents that can be used to trigger receivers.
- uses-library is used to specify the shared library that the application needs. You can specify whether a particular package is required or optional. When specified as necessary, an application cannot be installed on a device that lacks a specified library; when specified as optional, the application must use a reflection mechanism to check whether the library exists before attempting to use it.
<uses-library android:name="xx"
android:required="false"/>
1.2 Using Manifest Editor
ADT plug-in includes a Manifest Editor to manage Manifest, so that the underlying xml is not directly manipulated, and related nodes can be added and deleted directly through gui.
2. Use of resources
Common resource types are as follows
<string name="turn_off_auto_record">Turn off auto recording</string>
<plurals name="androidPlurals">
<item quantity="one">One android</item>
<item quantity="other">%d android</item>
</plurals>
<color name="app_bg">#ff0000ff</color>
<dimen name="def_border">5px</dimen>
<string-array name="string_array">
<item>1</item>
<item>2</item>
<item>3</item>
</string-array>
<array name="integer_array">
<item>3</item>
<item>2</item>
<item>1</item>
</array>
2.1 Reference to HTML tags in resources
Android supports simple text styles, so HTML tags can be used to make text strings bold, italic, and underscored.
<string name="test_string">Turn off auto recording<b>Stop.</b></string>
Resource strings can be used when entering parameters for the String.format method. String.format, however, does not support the text style described above. To style a formatted string, you need to escape to an HTML tag when creating a resource, as follows:
<string name="test_string">Turn off auto recording<b>Stop</b>.%1$s</string>
Within the code, you can use the Html.fromHtml method to convert these strings back into style character sequences:
String reString = getString(R.string.xx);
String fString = String.format(reString, "xx");
CharSequence styledString = Html.fromHtml(fString);
2.2 String Complex
Define the complex form for the string by plurals.
int unitCount = 2;
String unitString = getResources().getQuantityString(R.plurals.androidPlurals, unitCount, unitCount);
Object counts are passed in twice, once to return the correct complex number string, and once as an output parameter to complete the sentence.
2.3 colors
<color name="app_bg">#ff0000ff</color>
2.4 dimensions
size
px (pixels)
in (physical inch)
pt (physical point)
dp (non-density-constrained pixels)
sp (Scale Independent Pixels)
<dimen name="standard_boarder">5dp</dimen>
<dimen name="large_font_size">16sp</dimen>
2.5 Styles and Themes
Styles can be inherited, making it easy to create simple variants.
<style name="parentStyle">
<item name="android:textSize">10dp</item>
<item name="android:textColor">#112331</item>
</style>
<style name="childStyle" parent="parentStyle">
<item name="android:textSize">15dp</item>
</style>
2.6 Drawable
It includes bitmaps and. 9 png images, as well as complex composite Drawables, such as Level List Drawable and StateList Drawable, which can be defined in xml.
2.7 layout
Five layout
LinearLayout
RelativeLayout
FrameLayout
TableLayout
AbsoluteLayout
2.8 animation
Attribute animation can realize the function of complementary animation
Intermediate animation rotation, zooming, translation, fading in and out
Frame animation, such as video frame playback
2.9 Resource Reference
- Intra-Resource Reference
android:layout_height="@dimen/list_item_hight"
android:background="@drawable/info_background"
- Referencing System Resources
android:layout_marginTop="@android:dimen/app_icon_size"
- Referring to Styles in Current Topics
android:textColor="?android:textColor"
This way you can define styles that change with the current theme, without having to change each resource.
<activity
android:name="com.base.module.recorder.RecordActivity"
android:hardwareAccelerated="true"
android:label="@string/app_name"
android:configChanges="orientation|keyboard|mnc|locale">
</activity>
2.10 other
Override the onConfigChanged in Activity to listen for this change and handle it appropriately.
Android applications do not have complete control over their life cycle, and need to monitor the state of the program to make corresponding changes.
Using the Process tag in Manifest allows Activity to run in a separate process or in the same process for different processes.
3. Application Priority
When a system reclaims resources, the order in which processes are terminated is determined by their priority, and the priority of an application is equal to the highest priority of its components.
When two processes have the same priority, whoever runs on low priority for a long time will be terminated first.