How to Use the sample in Android

Source: Internet
Author: User
Tags android sdk manager

Original article address

Android Sample Apps

The android SDK uses des program sample apps that can help you learn Android by inspecting how different APIs are used to build a mobile application. these sample apps are available for download through the android SDK manager. learn how to easily create eclipse projects around und these Sample Apps, compile them, and use them in your own projects.

Part 0: getting started

This tutorial is for the Java developer just getting started learning Android app development, who is familiar with eclipse, and who has installed the android SDK with the android developer plugin for eclipse. if you are not prepared, see the previous tutorials in this series.

Step 1: Download the android Samples

The android SDK samples can be downloaded using the android SDK manager. the samples are organized by the API level they were designed for, and can be downloaded under the label "samples for SDK ". on a related note, the Google API add-on downloads tend to come with samples specifically to initialize strate their usage.

As you're aware, the android SDK manager downloads samples into a directory under your SDK installation. you cocould use these to start the project. you coshould even copy them out so you don't modify the originals. but, that's not how we're re going to do it! There's a better way!

Step 2: Start the sample project wizard

In eclipse, chooseFile> New> other..., Then expand the android folder, and choose "Android sample project ".

Step 3: Pick a build target

Next, you'll be presented with a list of Build targets. what you see here is directly related to which API level samples you have installed through the android SDK manager. what you see in our screenshot is probably overkill. few will want to target Android 1.1 (really ).

You can only choose one build target for your project. To follow along, choose Android 4.1, Android open source project, which is API level 16.

Step 4: Pick a sample project

On the next screen, you'll be shown a variety of compatible sample projects to choose from. projects that end in "> tests" are JUnit test projects that match up to a primary project. they are less interesting for the beginner, so stick to non-test projects for now.

Pick a sample project, then type in a name if you 'd like to change it. changing the name is useful if you 've already created the sample project once and want to create a new version within the sample eclipse workspace. to continue following along, pick apidemos. we're re naming it "apidemo 4.1" so as not to confuse it with other apidemos samples from other SDK versions.

Step 5: Release e a sample project

Your new project will now show up in eclipse. you can look through its files, packages, and the structure of the sample app. the apidemos sample app is special big, as it has sample code to demonstrate almost every core Android API.

Step 6: launch a sample project

Let's compile and launch our new sample project on the emulator. First, start your emulator and wait for it to fully launch (forget how this works? See Android Virtual Device creation ).

Next, chooseRun> run commands...

Double-click on Android Application (or right-click and choose new). On the first tab, choose the Browse... Button, pick your new sample project, and click OK.

Now fill in the Name field. we usually name our run deployments with the project name to avoid confusion but you can name it whatever you like. run and debug deployments have different options such that you cocould want multiple deployments for a single project.

On the target tab, check the radio button for "always prompt to pick device. "take note of some of the other run configuration options, like the network speed and latency; we're not going to use any of these options right now but it's worth knowing where they are.

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.