博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Android Package and Manifest File
阅读量:4046 次
发布时间:2019-05-24

本文共 3482 字,大约阅读时间需要 11 分钟。

The Android project, sometimes also referred to as an Android package, is a collection of Java packages. Different Android packages can have the same Java package names, whereas the Android package name must be unique across all applications installed on the Android device.

For the OS to access them, each application must declare its available components in a single AndroidManifest XML file. In addition, this file contains the required permissions and behavior for the application to run. Listing 2.5 shows what it looks like for the “Creating a Project and an Activity” recipe.

Listing  AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.cookbook.simple_activity"
android:versionCode="1"
android:versionName="1.0">

<application android:icon="@drawable/icon"

android:label="@string/app_name">

<activity android:name=".SimpleActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="3" />
</manifest>
The first line is required and standard across all XML files in Android to specify the
encoding.The manifest element defines the Android package name and version.The
versionCode is an integer that can be evaluated in programs to determine the upgrade or
downgrade relationship.The versionName represents a human readable format that can
have major and minor revisions declared.
The application element defines the icon and label the user sees from the Android
device menu.The label is a string and should be short enough to display under the icon
on a user’s device. Generally the name can be up to two words of ten characters each
without being cut off.
The activity element defines the main activity that is launched when the application
is started and the name shown in the title bar when the activity is active. Here, the Java
package name needs to be specified, which is com.cookbook.simple_activity.
SimpleActivity in this case. Because the Java package name is usually the same as
the Android package name, the shorthand notation is often used: .SimpleActivity.
However, it is best to remember that the Android package and Java package are
distinct.
The intent-filter element informs the Android system of the capabilities of the
component. It can have multiple action, category, or data elements for this purpose.This is
seen as it is utilized in different recipes.
The uses-sdk element defines the application programming interface (API) level
required to run this application. In general, the API level is specified as follows:
<uses-sdk android:minSdkVersion="integer"
android:targetSdkVersion="integer"
android:maxSdkVersion="integer" />
Because the Android OS is constructed to be forward compatible, the maxSdkVersion is
highly discouraged and not even adhered on devices with Android 2.0.1 or later. Specifying
the targetSdkVersion is not required, but allows devices of the same SDK version to
disable compatibility settings that might speed up operation.The minSdkVersion should
always be specified to ensure the application does not crash when run on a platform that does not support the required features in the application.Always choose the lowest API

level possible when specifying this.

The AndroidManifest can also contain permission settings needed to run the application.

转载地址:http://dogdi.baihongyu.com/

你可能感兴趣的文章
用Node.js实现Restful风格webservice
查看>>
REST简介
查看>>
理解RESTful架构
查看>>
nginx日志切割
查看>>
js函数的作用域与this指向
查看>>
腾讯QQ团队开源分布式后台服务引擎msec
查看>>
看看腾讯和百度等这样的大型网站系统架构是如何演化的
查看>>
AMQP与QPID简介
查看>>
nginx虚拟主机
查看>>
Nginx 性能调优
查看>>
nginx rewrite规则之last和break
查看>>
Redis和Memcached的区别
查看>>
Memcached 集群的高可用(HA)架构
查看>>
浏览器端的缓存规则
查看>>
redis持久化RDB和AOF
查看>>
Redis持久化存储(AOF与RDB两种模式)
查看>>
memcached工作原理与优化建议
查看>>
Redis与Memcached的区别
查看>>
redis sharding方案
查看>>
程序员最核心的竞争力是什么?
查看>>