讀書筆記[Android Beginning 2] chapter 1

Chapter 2 Projects and Targets


========

AndroidManifest.xml contains the "table of contents" for your application, listing all of the major application components, permissions, and so on.

The manifest is used by Android at runtime to tie your application into the OS.

The manifest contents are also used by the Android Market to specify the OS version.


========

Create a android project in command line:

android create project -n HelloAndroid -t 2 -p ./hello-android -a MainActivity -k apt.tutorial


========

Project Structure

AndroidManifest.xml

build.xml --> Ant

default.properties and local.properties --> Ant

assets/ --> A folder that holds other static files you wish packaged it with the application

bin/ --> A folder that holds the applcation once it is compiled

gen/ --> where Android's build tools will place source code that they generate.

libs/ --> A folder that holds anyy third party JARs your application requires.

src/ --> Java source code

res/ --> resources files(icons, gui layouts, strings, etc.)

tests/ --> A folder that holds an entirely sperate Android project used for testing the one you created.


Some files should not be checked in the Version Control Systems:

local.properities

bin/

gen/


========

Commands to build Android project

ant help

ant clean

ant compile

ant debug

ant release

ant install

ant uninstall


========

R.java: This contains a number of constants tied to the various resources you placed in the res/ directory tree.


========

res/drawable/: For images

res/layout/: For XML-based UI layout specifications

res/menu/: For XML-based menu specifications

res/raw/: For general-purpose files

res/values/: For strings, dimenstions and the like

res/xml/: For other general-purpose XML files you wish to ship


========

bin/classes/: Holds the compiled Java classes

bin/classes.dex: Holds the executable created from those compiled Java classes.

bin/yourapp.ap_: Holds your application's resources, packaged as a ZIP file.

bin/yourapp-debug.apk: application signed by the debug key.

bin/yourapp-unsigned.apk: build result of "ant release", the APK still needs to be signed using jarsigner and an official key.


========

AndroidManifest.xml

* package attribute:

* uses-permission elements:

* permission elements:

* instrumentation elements:

* uses-library elements:

* uses-sdk elements:

* application element:


========

activity element

    android:name: the class implementing the activity

    android:label: the display name of the activity

    intent-filter: describe under which conditions this activity will be displayed.


provider elements:

    --> content provider component, supply data to your activities and with your permission, other activities in other applications on the device.


service elements:

    long-running pieces of code that can operate independently of any activity.


========

If you want to ensure your application is run only on devices that have certain version or higher of the Android environment, you will add a uses-sdk element.

<uses-sdk minSdkVersion="2" />

If you omit the <uses-sdk> element, your application will behave as though minSdkVersion is set to 1.


1: Android 1.0 SDK

2: Android 1.1 SDK

3: Android 1.5 SDK

4: Android 1.6 SDK

5: Android 2.0 SDK

6: Android 2.0.1 SDK

7: Android 2.1 SDK

8: Android 2.2 SDK

9: Android 2.3 SDK

10: Android 2.3.3/4 SDK

11: Android 3.0 SDK

12: Android 3.1 SDK


========

Version = Control

you should add a pair of attributes to the root <manifest> element:

android:versionCode and android:versionName, these assist in the process of upgrading applications.

android:versionName attribute is some human-readable label for the version name or number of your application.

android:versionCode attribute is a pure integer indication of the version of the application. This is used by the system to determine if one version of your application is newer than another. Newer is defined as "has a higher android:versionCode value."

Simply increase the value of android:versionCode by one for each release of the application.


發佈了17 篇原創文章 · 獲贊 4 · 訪問量 5萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章