Fifth Chapter
Android uses a unified intent object to encapsulate the "start intent", providing a consistent programming model, whether it's initiating activity, service components, or broadcastreceiver. The intent design is somewhat similar to the logical view design in the STRUTS2 framework.
Intent is also an important medium for communication between application components: data is encapsulated into bundle objects, and intent carries bundle objects.
5.1 Intent Object Detailed
5.2 Intent Properties and Intent-filter configuration
5.2.1 Component Properties
5.2.2 Action, category attribute, and Intent-filter configuration
Intent by specifying the Action property, you can separate the intent from the specific activity to provide high-level decoupling.
Each intent can specify only one action requirement, but multiple category requirements can be specified.
Each component, through the <intent-filter.../> element, can declare that it meets multiple action requirements to meet multiple category requirements.
5.2.3 Specifies that the action, category invoke system activity, as long as permission is allowed. P298 Table 5.2 and Table 5.3 Start the activity's standard action constant and category constants. ( source \05\5.2\sysaction display System Contact list, remove name, phone )
5.2.4 Data, type attribute, and Intent-filter configuration
The data property is typically used to provide the Action property with the information of the operation, which accepts a URI object.
The Type property is used to specify the MIME type of the URI that the data refers to, and this MIME type can be any custom MIME type.
The relationship between the Data property and the Type property is subtle, and the two properties will overwrite each other, and if you want intent to have both the Data property and the type attribute, you should call the intent Setdataandtype () method.
( source \05\5.2\actiondata use action, Data property to start system activity)
5.2.5 Extra Properties
5.2.6 flag Attribute P311 common flag for intent
5.3 Creating tab pages with intent
( source \05\5.2\actiondata)
Sixth Chapter
The source code for Android apps can be divided into three main categories:
1 Interface Layout file: XML file, the label in the file corresponds to the corresponding view tag
2 Java source files: activity, Service, Broadcastreceiver, contentprovider four components in the app
3 resource files: Mainly various XML files, but also include picture resources.
6.1 Types of resources and how to store them
Android app resources can be divided into two main categories:
1 native resources that cannot be accessed through the R resource manifest class are saved in the assets directory.
2 resources that can be accessed through the R resource manifest class are saved in the Res directory.
Types of 6.1.1 resources and how they are stored
Table 6.1 P316
6.1.2 Using Resources
1 Using resource-clear items in Java code: [Package_name.] R.resouce_type.resource_name
2 access to the actual resources in Java code requires the use of the resource class provided by Android.
RESOURCE.GETXXX (int id): Gets the actual resource according to the resource manifest ID
Resource.getassets (): Gets the Assetmanager object that accesses the resource under the/assets/directory
3 using resources in XML files
6.2 Using strings, colors, size resources
Their corresponding XML files will be located in the/res/values directory.
6.2.1 Definition of color values
6.2.2 defining string, color, and size resource files
6.2.3 using strings, colors, size resources
6.3 Array Resource
Android uses the Arrays.xml file located in the/res/values directory to define the array
6.4 Using drawable Resources
6.4.1 Picture Resources
6.4.2 statelistdrawable resource: Used to organize multiple drawable objects.
( source \06\6.4\statelistdrawabletest highlight the text box being entered )
6.4.3 layerdrawable Resources, similar to the above, can contain an array of drawable, and the system will draw them in the order of the arrays, and the Drawable object with the largest index will be drawn at the top.
( source \06\6.4\layerdrawabletest custom Drag bar appearance )
6.4.4 shapedrawable resources are used to define a basic geometry.
6.4.5 clipdrawable Resource represents a fragment of a picture that is intercepted from another bitmap.
6.4.6 Animationdrawable Resource represents an animation
6.5 Properties Animation resource (property Animation)
Animator represents an attribute animation, but it is simply an abstract class that typically uses its subclasses: Animatorset, Valueanimator, Objectanimator, Timeanimator. ( source \06\6.5\animatortest)
6.6 Using raw XML Resources
6.6.1 defining the original XML resource
The original XML resource is typically saved under the/res/xml path and needs to be created manually.
6.6.2 using the original XML file ( source \06\6.6\xmlrestest)
6.7 Using Layout resources
6.8 Using the menu resource
6.9 style and Theme (Theme) resources
6.9.1 style resources are also placed under the/res/values directory
6.9.2 Theme resources are also placed under the/res/values directory
The difference between a theme and a style:
1 themes do not work on a single view component, and the theme should work for all the activity in the entire app, or for the specified activity.
2 Theme definition should be formatted to change the appearance of the window, such as window title, window border, and so on.
6.10 Attribute (Attribute) resource
( source \06\6.10\attrrestest)
6.11 using the original resource
Android's original resources can be placed in the following two places:
The 1/res/raw Android SDK will then generate an index entry for the resource under this directory in the R manifest class.
2/assets resources in this directory are more thorough primitive resources. Android apps need to manage the original resources in this directory through Assetmanager.
6.12 Internationalization and resource adaptability
Internationalization i18n
Localization l10n
6.12.1 The idea of Java internationalization
6.12.2 languages and countries supported by Java
6.12.3 completion of the process of national
6.12.4 provides international resources for Android apps
6.13 Adaptive resources for different screens