Android an open handset alliance project by k. Mahesh chandra


The Android platform itself



Download 276.25 Kb.
Page4/8
Date17.12.2020
Size276.25 Kb.
#55088
1   2   3   4   5   6   7   8
1 (1)
The Android platform itself

The Android platform is a Linux 2.6 kernel, a custom-made Java Virtual Machine called Dalvik, and a set of Java classes specially tailored for mobile use. The Google pages devoted to Android have lots of technical details. One important thing to understand is that all Android applications are in Java, and they all run as separate Linux processes. The Android system assigns each process a unique Linux user ID; this is the basis of the Android security model.



The SDK

You need to download the Android SDK as the first step.

Google recommends using the SDK as an Eclipse plugin. We found little value in doing that. We are mainly a NetBeans shop. We found that the easiest way to get started is simply to use the command-line tools.

And the tool to use is activityCreator.py, which creates an Activity. An Activity corresponds roughly to a "screen". You're building an application, which normally consists of a few Activitys. Applications can have other components, such as Services, but we'll start withActivitys.

activityCreator --out /home/me/MyApplication \

chiralsoftware.androidapp.MainActivity

This creates an activity called MainActivity in the chiralsoftware.androidapp package, in the /home/me/MyApplication directory. It also creates a helpful build.xml file.

The package is complete and ready to run. Let's try it out before making any changes.

Start the emulator. No arguments are needed:

emulator


You have two ways of deploying the application to the emulator. The easiest is to use the build.xml script, but we'll show you the command-line way first.

Build the app:

% ant

Buildfile: build.xml


dirs:

[mkdir] Created dir: /tmp/droid/bin/classes


resource-src:

[echo] Generating R.java...


aidl:
compile:

[javac] Compiling 2 source files to /tmp/droid/bin/classes


dex:
package-res:
package-res-no-assets:

[echo] Packaging resources...


package-dex:

[echo] Packaging dex...


package:
BUILD SUCCESSFUL

Total time: 3 seconds

This creates a file called bin/MainActivity.apk. Normal Java applications are shipped as Java Archive (JAR) files, which are essential ZIP files containing Java class files. Android applications instead use a .apk file, which is also a ZIP archive, but with a different format from a JAR file. In particular, a APK file does not have a META-INF or a MANIFEST.MF. It does have an AndroidManifest.xml file. It looks like this:


Download 276.25 Kb.

Share with your friends:
1   2   3   4   5   6   7   8




The database is protected by copyright ©ininet.org 2024
send message

    Main page