`
yidongkaifa
  • 浏览: 4052174 次
文章分类
社区版块
存档分类
最新评论

Android Package and Manifest File

 
阅读更多
The Android project, sometimes also referred to as an Android package, is a collection ofJava packages. Different Android packages can have the same Java package names, whereasthe Android package name must be unique across all applications installed on theAndroid device.

For the OS to access them, each application must declare its available components in asingle AndroidManifest XML file. In addition, this file contains the required permissionsand behavior for the application to run. Listing 2.5 shows what it looks like for the “Creatinga 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.

分享到:
评论

相关推荐

    Introduction.to.Android.Application.Development(4th,2013.12) pdf

    Editing the Android Manifest File 116 Managing Your Application’s Identity 122 Versioning Your Application 122 Setting the Application Name and Icon 122 Enforcing Application System Requirements 123 ...

    Android代码-apk-parser

    2. Get binary xml and manifest xml file 3. Get dex classes 4. Get Apk Sign info 5. Locales Open Issue Features Retrieve apk meta info, such as title, icon, package name, version, etc. Parse and ...

    Cross Platform Replay Kit Record Every Play.unitypackage

    • Auto-generates Android Manifest file. • Easy API for Recording • Easily convertible from Unity's ReplayKit API • Full source code is included. Feature set • Screen Record complete screen ...

    新版Android开发教程.rar

    The sections below describe the system and software requirements for developing Android applications using the Android SDK tools included in Android 1.1 SDK, Release 1. Supported Supported Supported ...

    ContentProvider

    &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.tigongzhe" android:versionCode="1" android:versionName="1.0" &gt; android:minSdkVersion="8" android:...

    Google Android SDK开发范例大全(完整版)

    为了在 Eclipse 中创建应用程序,选择 File &gt; New &gt; Android project,这将启动 New Android Project 向导。 图 5. New Android project 向导 接下来,创建一个简单的应用程序,该应用程序有一个活动,并且在 ...

    archonpackager

    App Name and package name are both pulled from the APK and put into the manifest.json file. Everything is then zipped together in a ChromeAPK folder on your phones storage. Requires ...

    apk_parser.dart:一个解析android apk数据的纯dart库

    apk_parser 一个解析android apk数据的纯dart库 这是一个正在进行的工作 用法 一个简单的使用示例: import 'dart:io' ; import 'package:apk_parser/apk_parser.dart' ;... Package : ${ manifest.packa

    android-viewflow

    Again, note that it's the application namespace and not the viewflow namespace that must be referred like xmlns:app="http://schemas.android.com/apk/res/your.application.package.here". In your ...

    android实习报告(1).doc

    创建的文件保存在/data/data/&lt;package name&gt;/files目录,如: /data/data/cn.itcast.action/files/itcast.txt ,通过点击Eclipse菜单"Window"-"Show View"- "Other",在对话窗口中展开android文件夹,选择下面的File...

    apktool documentation

    Automatically detects differences between resource and manifest and performs automatic --rename-manifest-package on [b]uild versionInfo - Used to repopulate the version information in ...

    解决Installation error: INSTALL_FAILED_INSUFFICIENT_STORAGE

    解决 Installation error: INSTALL_FAILED_INSUFFICIENT_STORAGE 试试修改一下manifest文件 &lt;manifest xmlns:android=... package="com.andrewsmith.android.darkness" android:installLocation="preferExternal

    adb1.0.26包含fastboot.exe

    ADB,即 Android Debug Bridge,它是 Android 开发/测试人员不可替代的强大工具,也是 Android 设备玩家的好玩具。 注:有部分命令的支持情况可能与 Android 系统版本及定制 ROM 的实现有关。 基本用法 命令语法 ...

Global site tag (gtag.js) - Google Analytics