Before the Android system can start an app component, the system must know that the component exists by reading the app'sAndroidManifest.xmlfile (the "manifest" file). Your app must declare all its components in this file, which must be at the root of the app project directory. 

The manifest does a number of things in addition to declaring the app's components, such as:

  • Identify any user permissions the app requires, such as Internet access or read-access to the user's contacts.
  • Declare the minimumAPI Levelrequired by the app, based on which APIs the app uses.
  • Declare hardware and software features used or required by the app, such as a camera, bluetooth services, or a multitouch screen.
  • API libraries the app needs to be linked against (other than the Android framework APIs), such as theGoogle Maps library.
  • And more

  Activities, services, and content providers that you include in your source but do not declare in the manifest are not visible to the system and, consequently, can never run. However, broadcast receivers can be either declared in the manifest or created dynamically in code (asBroadcastReceiverobjects) and registered with the system by callingregisterReceiver().

  For every resource that you include in your Android project, the SDK build tools define a unique integer ID, which you can use to reference the resource from your app code or from other resources defined in XML. For example, if your app contains an image file namedlogo.png(saved in theres/drawable/directory), the SDK tools generate a resource ID namedR.drawable.logo, which you can use to reference the image and insert it in your user interface.

  One of the most important aspects of providing resources separate from your source code is the ability for you to provide alternative resources for different device configurations. For example, by defining UI strings in XML, you can translate the strings into other languages and save those strings in separate files. Then, based on a languagequalifierthat you append to the resource directory's name (such asres/values-fr/for French string values) and the user's language setting, the Android system applies the appropriate language strings to your UI.

更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. 每天一算:Contains Duplicate II
  2. 每天一算:Remove Nth Node From End of Li
  3. 【图解数据结构】 一组动画彻底理解选择
  4. 每天一算:Valid Parentheses
  5. 每天一算:Reverse String
  6. 【图解数据结构】 一组动画彻底理解快速
  7. 每天一算:Evaluate Reverse Polish Notati
  8. 每天一算:Remove Linked List Elements
  9. 【图解数据结构】 一组动画彻底理解插入
  10. 每天一算:Binary Tree Preorder Traversal