Monday, December 31, 2012

android note

0. Install JDK6 and eclipse (classic eclipse-SDK-3.7.1-win32.zip).
1. Download the Android SDK starter package and unzip the package.
http://dl.google.com/android/android-sdk_r15-windows.zip
D:\android\sdk\android-sdk_r15-windows\android-sdk-windows
2. Run SDK Manager.exe to add Android platforms and other components to your SDK.
3. Install ADT Plugin
  Start Eclipse, then select Help > Install New Software....
  Click Add, in the top-right corner.
  Browse and select the downloaded zip file.
  Enter a name for the local update site (e.g., "Android Plugin") in the "Name" field.
  Click OK/Next/Finish.
  When the installation completes, restart Eclipse.
4. Configuring the ADT Plugin
  Window > Preferences -> Android
  For the SDK Location in the main panel, click Browse... and locate your downloaded SDK directory.
  
All applications are written using the Java programming language.
The Android SDK tools compile the code—along with any data and resource files—into an Android package, an archive file with an .apk suffix. All the code in a single .apk file is considered to be one application and is the file that Android-powered devices use to install the application.
Each process has its own virtual machine (VM), so an application's code runs in isolation from other applications.
Dalvik has been written so that a device can run multiple VMs efficiently. The Dalvik VM executes files in the
Dalvik Executable (.dex) format which is optimized for minimal memory footprint. The VM is register-based, and runs classes compiled by a Java language compiler that have been transformed into the .dex format by the included "dx" tool.   

Android applications are composed of one or more application components (activities,
services, content providers, and broadcast receivers)
The manifest file must declare all components in the application and should also declare all application requirements, such as the minimum version of Android required and any hardware configurations required.

However, there are ways for an application to share data with other applications and for an application to access system services:

It's possible to arrange for two applications to share the same Linux user ID, in which case they are able to access each other's files. To conserve system resources, applications with the same user ID can also arrange to run in the same Linux process and share the same VM (the applications must also be signed with the same certificate).
An application can request permission to access device data such as the user's contacts, SMS messages, the mountable storage (SD card), camera, Bluetooth, and more. All application permissions must be granted by the user at install time.
An activity represents a single screen with a user interface.
A service is a component that runs in the background to perform long-running operations or to perform work for remote processes. A service does not provide a user interface.
A content provider manages a shared set of application data.Through the content provider, other applications can query or even modify the data (if the content provider allows it).
A broadcast receiver is a component that responds to system-wide broadcast announcements. Many broadcasts originate from the system—for example, a broadcast announcing that the screen has turned off, the battery is low, or a picture was captured. Although broadcast receivers don't display a user interface, they may create a status bar notification to alert the user when a broadcast event occurs.
When the system starts a component, it starts the process for that application (if it's not already running) and instantiates the classes needed for the component. For example, if your application starts the activity in the camera application that captures a photo, that activity runs in the process that belongs to the camera application, not in your application's process. Therefore, unlike applications on most other systems, Android applications don't have a single entry point (there's no main() function, for example).

Three of the four component types—activities, services, and broadcast receivers—are activated by an asynchronous message called an intent.
An intent is created with an Intent object, which defines a message to activate either a specific component or a specific type of component—an intent can be either explicit or implicit, respectively.

The other component type, content provider, is not activated by intents. Rather, it is activated when targeted by a request from a ContentResolver. The content resolver handles all direct transactions with the content provider so that the component that's performing transactions with the provider doesn't need to and instead calls methods on the ContentResolver object. This leaves a layer of abstraction between the content provider and the component requesting information (for security).

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 (as BroadcastReceiver objects) and registered with the system by calling registerReceiver().

An Activity is simply a class that can run and do work. It can create a UI if it chooses, but it doesn't need to.

No comments:

Post a Comment