Start of my Android 4 learning series: Configuring the development environment and understanding Hello world!

Source: Internet
Author: User
Tags android sdk manager

Directory

    • How to install the Android SDK, create a development environment, and debug projects
    • Some considerations in mobile design
    • Using Android virtual devices, emulators, and other development tools

How to install the Android SDK, create a development environment, and debug projects

To download and install the Android SDK:

My is window7 system, of course Download SDK starter Package most suitable: http://developer.android.com/sdk/index.html

After downloading, open the compressed package as follows:

Then unzip the package into a directory and run the SDK Manager.exe:

These include platform tools, each platform version, and a set of extra nodes.

check boxes for the latest Framework SDK and the latest version tools, compatibility/support packs, documentation, and sample code are selected for download.

You can use the Android SDK Manager to download and install updates when new Android Framework SDKs, development tools, sample code, documentation, compatibility libraries, and third-party add-ins are available.

ADT Plugin features for eclipse:

    • Integrated Android Project Creation Wizard.
    • Form-based manifest files, layouts, and resource managers to help you create, edit, and validate XML resources.
    • Automatically build Android project, convert to Android executable file. dex, package file. apk, and install the package to the Dalvik virtual machine (which can run on virtual machines and actual devices).
    • Android Virtual Device Manager: Run a specific version of the Android OS, set hardware and memory limits.
    • Android Simulator: appearance, network connection settings and the ability to simulate incoming calls, SMS messages.
    • Dalvik Debug Monitoring Service (Dalvik Debug monitoring Service,ddms), including: Port forwarding (ports forwarding), stack, heap and thread view, process details and screen capture capabilities.
    • Access to the file system of the device or emulator, allowing browsing of directories and transferring files.
    • Run debugging. Set breakpoints and view call stacks.
    • All the Android/dalvik logs and console outputs.

To install the ADT plugin: It's fairly simple, like.

Eclipse Select help| Install New Software:

Create and understand the first HelloWorld program:

(1) Select Eclipse's file| new| Project| Android Application Type | Next:

(2) After filling in the information, a default Hello World program is created.

Of course, you have to create a virtual device AVD:

(1) Eclipse Select window| AVD manager| Create:

(2) Fill in the information can be OK.

You also need to create a boot configuration:

    • The project and activity to start
    • Deployment targets (virtual devices and time devices)
    • Startup parameters of the simulator
    • Input/Output settings (including default consoles)

Creation and setup are simple:

Fill in the information and apply to save the current settings.

Finally run and debug (F5 doesn't work):

Of course I chose run/debug.

Understand what HelloWorld is:

Activity is the base class for interactive components that are visible in the application, presumably equivalent to form forms in desktop application development. Androidbaractivity is supported in the Library class can be compatible with the 2.x version, the activity provided by the Actionbar only more than 3.0 can be used.

Package Com.example.hello;

Import android.support.v7.app.ActionBarActivity;
Import Android.os.Bundle;
Import Android.view.Menu;
Import Android.view.MenuItem;

public class Mainactivity extends actionbaractivity {

@Override
protected void OnCreate (Bundle savedinstancestate) {
Super. onCreate (savedinstancestate);
Setcontentview (R. Layout.activity_main);
}
}

In Android, a visual component is called a view, which resembles a control in a traditional desktop app development.

Setcontentview is used for layout, of course, by passing in the parameter: layout resources. Therefore, the OnCreate method must be overridden.

Notice the R variable: Provides design-time access to the resource.

<relativelayout xmlns:android= "Http://schemas.android.com/apk/res/android"
Xmlns:tools= "Http://schemas.android.com/tools"
Android:layout_width= "Match_parent"
android:layout_height= "Match_parent"
android:paddingbottom= "@dimen/activity_vertical_margin"
android:paddingleft= "@dimen/activity_horizontal_margin"
android:paddingright= "@dimen/activity_horizontal_margin"
android:paddingtop= "@dimen/activity_vertical_margin"
tools:context= "Com.example.hello.MainActivity" >

<textview
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
android:text= "@string/hello_world"/>

</RelativeLayout>

There are two ways of defining the UI:

(1) XML, which separates the application logic from the UI.

The access UI element in code is obtained through the identifier property, for example:

<textview android:id= "@+id/mytextview"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
android:text= "@string/hello_world"/>

Code access: TextView Mytextview = (TextView) Findviewbyid (R.id.mytextview);

(2) Code, use as needed.

Some considerations in mobile design

App Types for Android:

    • Foreground application
    • Background applications
    • Intermittent applications
    • Widgets and Live Wallpaper

Features of mobile devices:

    • Low processing capacity
    • Limited RAM
    • Limited capacity for permanent storage
    • Low-resolution small screen
    • Higher costs associated with data transfer
    • Unstable connection, low speed data transfer rate, high latency
    • More unreliable data connections
    • Limited battery life

Considerations in Development:

    1. Efficient
    2. Consider a limited capacity
    3. Design for different screens
    4. Consider low rate, high latency
    5. How much will it cost

Using Android virtual devices, emulators, and other development tools

1. Android Virtual Device Manager

Can be set:

    • Virtual machine Maximum Heap size
    • Pixel density of the screen
    • SD card support
    • Do you have hardware such as dpad, touch screen, keyboard, and track ball
    • Accelerometer, GPS, and distance sensor support
    • Memory for available devices
    • Camera hardware (and resolution)
    • Recording support
    • Do you have hardware back and home keys

2. Android SDK Manager

3. Android Simulator

4. DDMS: Allows viewing of activity processes, viewing stacks, viewing and pausing activity threads, and browsing the file system of any connected Android device

5. Android Debug Bridge (ADB): A client-server application that allows the connection of any Android device (real or virtual) it consists of three components,

    • A daemon that runs on a device or emulator
    • A service that runs on the development computer
    • A client application that communicates with the daemon through a service (for example: DDMS)

6. Hierarchy Viewer and Lint tools: Help Analyze, Debug, and optimize the XML layout definitions used within the application.

7. Monkey and Monkey Runner: used to test the stability of an application in a UI view.

Monkey to be used in the ADB shell, it sends a pseudo-random system and UI event flow to the application. Monkey is useful when you stress-test your application to see if the unconventional use of the UI can cause problems when you might not think of an edge situation

Monkey Runner is a Python scripting API that allows special UI commands to be sent to control the emulator or device from outside the application. It is important to perform UI testing, functional testing, and unit testing in a predictable, repeatable manner.

The above several tools seem more powerful oh, behind slowly drop research AH!!!

Q&a

Q: When Android starts the simulator AVD, the following exception appears: "Failed to allocate Memory:8", what to do?

A: Reduce the allocated memory size. Modify the AVD profile to change the option "hw.ramsize=1024" from 1024 to 256. :

Today press Ctrl+s before a sudden power outage, write a lot, but I lost it again and again, Moon I also.

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.