[Android Basics] 004. Run the App

Source: Internet
Author: User

Run your app
这篇课程会教你:1、如何在设备上运行你的app。2、如何在模拟器上运行你的app。当然,在学习之前,你还需要知道:1、如何使用设备。2、如何使用模拟器。3、管理你的项目。

In the last lesson we created an Android project. It can be run directly. When we create it, it will default to help us write a Hello world! The interface. You can see it running.

At the moment of running the item, let's take a look at the various directories and files of the Android project.

Androidmanifest.xml

manifest, manifest, the meaning of the bill. when you understand the role of this file, you know why Google is giving it the name. Androidmanifest.xml, in this file, defines the basic features of the app and every component that the app uses. Just like a list, in this file, you define what features, functions, permissions, components, etc. of the app. well-trained programmers, by reading this list, know what the app does, otherwise, you download an app to your phone, how do you think your phone knows the use rights of these apps? is known through it. Androidmanifest.xml (App list) has a lot of content to say, but at the beginning, we just need to know a few basic but important points on it.

The first things you need to know are:

<uses-sdk>

<uses-sdk> defines the compatibility of this app. We know that there are many versions of Android, from Android 1.0, which was released in September 2008, to Android 1.5 (cupcake cupcakes), which was later named after the dessert, to the later Android 4.0 with a very high market share (icecream Sandwich Ice Cream Sandwich), to the current October 15, 2014 release of the highest Android version: Android 5.0 (Lollipop Lollipop), if you want to make your app compatible with different versions of Android, you must rely on this tag. Take an example of the project we created earlier, with the following code:

    < USES-SDK         android:minsdkversion = "8"         android:targetsdkversion= "/> "

You can define app compatibility by setting Android:minsdkversion and Android:targetsdkversion. minsdkversion, defines the minimum Android version that the app can be compatible with. Targetsdkversion, defines the SDK version used to develop the app and compile the app.

src/

This directory is the directory where the project's Java source files are stored.

res/

This directory holds the resources for the app. such as: Pictures, sound, app layout files, international voice information, animation, ID and so on. In this column a few res/subdirectories.

drawable-hdpi This directory contains high-definition images. The phone has a lot of different resolutions, to make an app can be in a lot of resolution of the perfect display, need multiple sets of pictures. Encounter high resolution, use high-definition diagram, encounter low resolution, use low-clear map. drawable-hdpi, the picture here is for mobile phones with high display pixels.

Layout The directory where the UI layout files are stored. The app needs the interface, the interface needs layout, here is the layout file for the layout of the interface.

value The meaning of the value. many kinds of XML files are stored here, such as string.xml (definition String), Color.xml (definition color), and so on.

run the app on your device

Prepare an Android phone. Let's install the first app on the device together. If you're a Mac, turn on Eclipse, connect your phone to your computer using a USB cable, and you'll see the device ID number you're connected to in the Eclipse's device window.

Right click on the project->run as->android application, you can run the project to the phone. Double-click, run, very simple, see if there is a robot icon on your desktop, click, you will see a text interface with Hello World appears on the phone screen!

running the app on the emulator

After Eclipse Android is on the ADT plugin, it becomes (Eclipse + ADT). This IDE has an Android simulator, which is a thing that simulates the environment of an Android phone running on a computer, and if there is no Android phone, you can also run the app to debug on this Android simulator. It's very slow, it's not very good, but it's handy if you're debugging the interface, because you can't borrow so many different models of phones, and this simulator can also emulate them.
Running the simulator is simple, click the Small robot icon on the toolbar above eclipse to create an emulator. :

This is the simulator creation window, because it is not recommended to use the simulator, this is not said, the interface is very simple, their own research can be.

This site article is for baby bus SD. Team Original, reproduced must be clearly noted: (the author's official website: Baby bus )
Reprinted from "Baby bus Superdo Team" original link: http://www.cnblogs.com/superdo/p/4493142.html

[Android Basics] 004. Run the App

Related Article

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.