Android Learn three---create the first program

Source: Internet
Author: User

1. Create a HelloWorld program 1.1 new-android Application

Click File-new-android Application The following screen appears

Fill in the Application name, project name, package name, select the minimum required SDK version, target version and compiled version, next next

Select an activity, the default is blank. Then finish.

The good one Android project is created. You don't need to add any code to run it.

2. Create a virtual machine and run a 2.1 emulator on a real machine

Open the AVD button on the toolbar

Interface for creating VD (virtual machine) appears

Click on creat to create the.

It mainly has the name of the Android virtual device, the target object (SDK), the path of the SD Card, and the skin of the virtual device, etc.

Two items in red: One is to select CPUs with Arm and X86 (Atom). Second, the Analog way

The difference between the snaphost and the use Host GPU

The Snapshot option speeds up the boot of the emulator by saving a Snapshot of its RAM once it has booted, and re Storing from this snapshot on the future uses. That, it doesn ' t has to run the boot process (which is slow, because it's emulated) every time you start the emulator .

The use host GPUs option uses the host computer ' s OpenGL implementation (which is probably hardware-accelerated, O n your real GPU) to evaluate OpenGL commands inside the emulated system. Put another, when a program inside the emulator uses OpenGL for graphics operations, the work goes off to your real GP U, and the result goes back to the emulator, instead of emulating a GPU (which is very slow). The result is a significant speed-up, especially if you consider that most view and canvas drawing uses OpenGL in Androi D≥4, even in non-graphics apps.

You can ' t has both options turned on at once.

The snapshot accelerates the start of the emulator by saving a snapshot of the ram at boot. So you don't need to run the boot process every time you start the emulator.

Use host GPU: Using the OpenGL implementation of the host computer, when emulator needs to use OpenGL, it uses the computer's GPU instead of the simulation, so it can speed up some graphics processing.

If the computer performance is general, it is best to choose Snapshot.

A program that appears as above indicates a successful creation. Before this, please be patient and start the process for a long time.

Simple use of the program

2.2 Real-machine operation

Need an Android phone to be able to connect to the computer and drive it down well. At this point run as Android application. There will be a machine that appears in the options below,

If you have an Android phone, it is best to choose the real machine for debugging, the virtual machine boot is too slow, installation, running time is also long.

3.android Project directory Structure

Mainly introduce several

3.1 src:

are all packages and source files (. java) of the project to implement the functions of the application, etc.

3.2 Res:

The folder contains the items in the
All resources, such as program icon (drawable), layout file, constants (values), etc.

3.3 Gen:

Represents the automatically created file, where R.java is automatically generated when the project is built, this file is read-only, cannot be changed, R.java file is defined for all
The index file for the resource.

3.4 Androidmanfest.xml:

The Androidmanfest.xml file contains the Activity, service, Receiver used in the project.

Android Learn three---create the first program

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.