[学习笔记]Application Fundamentals

2019-07-14 11:53发布

参考资料:http://developer.android.com/guide/components/fundamentals.html
         APK: an Androidpackage, which is an archive file with an .apk suffix        APK:一个以.apk为后缀的带存档的Android   Once installed on a device, each Android app lives in itsown security sandbox: -The system sets permissions for all thefiles in an app so that only the user ID assigned to that app can access them -Each process has its own virtualmachine (VM), so an app's code runs in isolation from other apps. 一旦被安装在设备上,每一个Android应用处于独立的安全沙盒: -系统对一个应用中的所有文件设置权限,以致只有被赋予的唯一ID可访问 -每个进程都有独立的虚拟机,所以一个应用的代码运行在一个隔离区   principle of least privilege. That is, each app, by default, has access only to thecomponents that it requires to do its work and no more.  最少特权原则.就是说,默认地,每个应用只有它所需用到的权限   It's possible to arrange for two apps to share the sameLinux user ID, in which case they are able to access each other's files.          当两个应用可以相互访问文件,则可能它们可共享相同的Linux user ID App Components                        ActivityAn activity represents a single screen with a userinterface. 一个activity表示一个带UI的单屏幕   Servicesservice is a component that runs in thebackground to perform long-running operations or to perform work for remoteprocesses. 一个service是运行在后台去执行长期操作或进行远程操作的组件   Content providerscontentprovider manages a shared setof app data. 提供应用数据的共享集   Broadcast receiversbroadcastreceiver is a component thatresponds to system-wide broadcast announcements. Many broadcasts originate fromthe system 对系统行为的响应   A unique aspect of the Android system design is that any appcan start another app’s component.  不同应用的组件可以相互调用,如Camera So, to activate a component in another app, you mustdeliver a message to the system that specifies yourintent tostart a particular component. The system then activates the component for you. 所以,为了启动其他应件,你须传递一个信息,去确定启动一个特定组件的Intent。然后,系统为你启动该组件 The Manifest File                           -Identify any user permissions the app requires -Declare APILevel required by the app -Declare hardware and software features used or required bythe app 权限、API版本、软硬件特性   Declaringcomponents 声明四大组件    However, the real power of intents lies in the concept of implicitintents. An implicit intent simply describe the type of action toperform and allow the system to find a component on the device that can performthe action and start it. If there are multiple components that can perform theaction described by the intent, then the user selects which one to use. Intent的威力在于隐式调用,描述动作而允许系统去寻找组件来实现。如果有多种选择,由用户决定 App Resources                              Using app resources makes it easy to update various characteristicsof your app without modifying code and by providing sets of alternativeresources—enables you to optimize your app for a variety of deviceconfigurations (such as different languages and screen sizes). 使用资源,便于优化和兼容   /res