Android Programming: Pushing the Limits -- Chapter 3: Components, Manifests, and Resources

Android Components
Manifest文件
Resource and Assets

Android Components

@ActivityServicesBroadcastReceiversContentProvidersApplication

@Activity

1、  负责user interface

2、  Android 3.0(Honeycomb)开始,使用Fragment实现界面动态调整。

@Services

1、  实现后台执行操作。

@BroadcastReceivers

1、  监听系统事件。

@ContentProviders

1、  存储数据。

@Application

1、开发前,使用组件来构造应用的框架。暂时只描述组件的功能,而不需完整设计好。

 

Manifest文件:

@<manifest>的属性可以定义:应用的包名,唯一标志符(package),应用运行的Linux用户id(sharedUserId)和名称(sharedUserLabel),版本信息(versionCode, versionName),安装位置(installLocation)

@<user-feature>描述安装此应用需要的条件。用于Google Play进行过滤。

You can find a complete list of all the standard features in Android at

http://developer.android.com/guide/topics/manifest/uses-feature-element.html#features-reference

@<supports-screens>描述安装此应用需要的屏幕大小。

@<uses-sdk>描述应用的Android版本(minSdkVersion, maxSdkVersion, targetSdkVersion)。如果可能的话,最好不指定maxSdkVersion

You can find a complete list of all API levels and which Android version they represent at

http://developer.android.com/guide/topics/manifest/uses-sdk-element.html

@<application>

name:当使用自定义的应用类时,可通过此属性指定对应的类名,否则不需要使用此属性。

backupAgent:指定用来备份的类,用来帮助用户进行应用迁移而不丢失应用的数据。

largeHeap:最大内存需求,当设备内存小于此设置时,系统极可能就会终止应用,不建议使用此属性。

process:具有同个用户id(<manifes>中指定的sharedUserId)的应用,如果此属性设置一样,则会强制使用相同的进程。这种情况,如果一个应用崩溃将影响使用同一进程的其他应用。

theme:设置整个应用的主题。注:Activities可以独立设置主题。

@、组件属性

enabled:如果设置为falseActivities不会显示;Services不会对startService方法作出反应;BroadcastReceivers不会监听BroadcastIntentsContentProviders不会回应ContentResolver

exported:如果设置为false,则不会暴露给系统的其他应用。

@<intent-filter>依赖因素:<action><category><data>

You can read more about Intents and Intent resolution for Android at

http://developer.android.com/guide/components/intents-filters.html

 

Resources and Assets:

@You can find a list of all the resource qualifiers, their order of precedence, and their meaning at http://developer.android.com/guide/topics/resources/providing-resources.html#table2

@You can find detailed rules on formatting resource strings in the JavaDoc for the java.util.

Formatter class at http://developer.android.com/reference/java/util/Formatter.html

@<plurals>,在代码中通过getQuantityString()获取值。

@Localization

You can access the Google Translator Toolkit at http://translate.google.com/toolkit

@A great site for finding the mobile country codes (MCC) and mobile network code (MNC) values for various carriers and countries is www.mcc-mnc.com

@、从Android 2.3开始,resource文件大小限定为1M。而在assets目录下的没有限制。

 

原文地址:https://www.cnblogs.com/yarightok/p/5604658.html