android 官文摘要

来源:互联网 发布:减速机 知乎 编辑:程序博客网 时间:2024/06/04 00:26

1.mipmap/ directories for launcher icons,
mipmap目录为桌面运行图标
2.Android selects which alternative resource to use at runtime, depending on the current device configuration.
在运行时会根据设备配置,系统会自动选择可选的资源
2.1 All resource IDs are defined in your project's R class, which the aapt tool automatically generates.

3.if you want to prevent runtime restarts due to orientation change when developing for API level 13 or higher (as declared by the minSdkVersion and targetSdkVersion attributes), you must include the "screenSize" value in addition to the "orientation" value. That is, you must decalare android:configChanges="orientation|screenSize".
 在13版本或者更高,如果想防止由于orientation的发生改变而引起activity重启需要设置 screenSize|orientation
4.Once installed on a device, each Android app lives in its own security sandbox
一旦安装,app会运行在自己的沙箱里
5.By default, the system assigns each app a unique Linux user ID (the ID is used only by the system and is unknown to the app).
  默认的,系统会为每一个app分配独一无二的用户id
6. a different app can start any one of these activities
不同的app可以启动他们某一个acticity
7. the system must know that the component exists by reading the app's AndroidManifest.xml file (the "manifest" file).
组件必须注册
8.The Intent describes the activity to start and carries any necessary data.The Intent describes the service to start and carries any necessary data.
intent信息的载体
9. if you do not declare any intent filters for an activity, then it can be started only with an explicit intent
如果你没有声明过滤器,只能通过显示启动一个activity
10. To ensure your app is secure, always use an explicit intent when starting a Service and do not declare intent filters for your services. Using an implicit intent to start a service is a security hazard because you cannot be certain what service will respond to the intent, and the user cannot see which service starts. Beginning with Android 5.0 (API level 21), the system throws an exception if you call bindService() with an implicit intent
确保安全,应该用显示意图启动一个服务,不要定义过滤器.因为隐示意图无法确定哪个服务会响应.到5.0版本开始如果使用隐士意图,绑定服务会报异常
11.When starting a Service, you should always specify the component name. Otherwise, you cannot be certain what service will respond to the intent, and the user cannot see which service starts.
建议用显示意图开启一个服务
12.If you define your own actions, be sure to include your app's package name as a prefix.
建议用包名当action的前缀
13.So specifying the MIME type of your data helps the Android system find the best component to receive your intent
建议定义数据类型,系统会为你选择适合的app响应
14.if (sendIntent.resolveActivity(getPackageManager()) != null) {
     Intent chooge=  Intent.createChooser(intent,"hello");
                startActivity(chooge);;
}校验intent 是否可以被解析(被某一个activity回应)没有null.多个应用相应时hello是标题
15. The system will deliver an implicit intent to your app component only if the intent can pass through one of your intent filters.
16.In order to receive implicit intents, you must include the CATEGORY_DEFAULT category in the intent filter--If you do not declare this category in your intent filter, no implicit intents will resolve to your activity.the intent must pass all three tests(action data,catagory验证). If it fails to match even one of them, the Android system won't deliver the intent to the component (原因 Android automatically applies the the CATEGORY_DEFAULT category to all implicit intents passed to startActivity() and startActivityForResult(). So if you want your activity to receive implicit intents, it must include a category for "android.intent.category.DEFAULT" in its intent filters (as shown in the previous <intent-filter> example)
当用隐示意图开启一activity时必须为intent-filter action添加CATEGORY_DEFAULT,因为系统自动的添加CATEGORY_DEFAULT这个action.
17.If the <activity> element does not specify an icon with icon, then the system uses the icon from the <application> element.The ACTION_MAIN action indicates this is the main entry point and does not expect any intent data.

18. If you want to modify the options menu based on events that occur during the activity lifecycle, you can do so in the onPrepareOptionsMenu() method。进行修改....you want to perform a menu update, you must call invalidateOptionsMenu() to request that the system call onPrepareOptionsMenu().(3.0)
19.The main content view (the FrameLayout above) must be the first child in the DrawerLayout because the XML order implies z-ordering and the drawer must be on top of the content.
The main content view is set to match the parent view's width and height, because it represents the entire UI when the navigation drawer is hidden.
The drawer view (the ListView) must specify its horizontal gravity with the android:layout_gravity attribute. To support right-to-left (RTL) languages, specify the value with "start" instead of "left" (so the drawer appears on the right when the layout is RTL).
The drawer view specifies its width in dp units and the height matches the parent view. The drawer width should be no more than 320dp so the user can always see a portion of the main content(drawablelayout 使用注意对象.........)
20.A content provider presents data to external(外部的) applications as one or more tables that are similar to the tables found in a relational(相关的) database.(内容提供者只是用uri 和在重写的方法里调用数据库crud 方法而已,而解析者拿着uri 去比对,至于哪个匹配,看系统....)
21The ContentResolver object in the client application's process and the ContentProvider object in the application that owns the provider automatically handle inter-process communication 自动跨进程交流
22.compiledSdkVersion: By default, this is set to the latest version of Android SDK installed on your development machine.
23.The plus sign (+) before the resource type is needed only when you're defining a resource ID for the first time. When you compile the app, the SDK tools use the ID name to create a new resource ID in your project's gen/R.java file
24.if the system destroys the activity due to system constraints (rather than normal app behavior), then although the actual Activity instance is gone, the system remembers that it existed such that if the user navigates back to it, the system creates a new instance of the activity using a set of saved data that describes the state of the activity when it was destroyed. The saved data that the system uses to restore the previous state is called the "instance state" and is a collection of key-value pairs stored in a Bundle object:如果系统因为内存不足或者其他约束因为而销毁acticitty,但系统会保存数据在Bundle object,当用户在返回他时,会使用已经保存的数据,创建一新activity对象
25.In order for the Android system to restore the state of the views in your activity, each view must have a unique ID, supplied by the android:id attribute.
保证独一无二的id系统才能正确的恢复views状态
26.If the app wants to use resources or information outside of its sandbox, the app has to explicitly request permission
//如果app想使用沙箱外的资源或者信息,需要权限请求.
27.If you've set your targetSdkVersion to 17 or higher, you must add the @JavascriptInterface annotation to any method that you want available to your JavaScript (the method must also be public). If you do not provide the annotation, the method is not accessible by your web page when running on Android 4.2 or higher.
17或者更高版本,在jscript调用android 里面的方法,这个方法必须用@javascriptInterface注释,否则没有用

ps:翻译只是大概的意思,待续.
0 0
原创粉丝点击