[Android]Android Hello World Example

In this tutorial, we show you how to create a simple “hello
world” Android project in Eclipse IDE +
ADT plugin
, and run it with Android Virtual Device
(AVD)
. The Eclipse ADT plugin provided easy Android project creation
and management, components drag and drop, auto-complete and many useful features
to speed up your Android development cycles.

Summary steps to develop an Android application :

  1. Install Android SDK

  2. Install ADT Eclipse plugin

  3. Create an Android Virtual Device (AVD)

  4. Create Android Project with Eclipse (Wizard)

  5. Code it…

  6. Start it in Android Virtual Device (AVD)

Tools used in this tutorial :

  1. JDK 1.6

  2. Eclipse IDE 3.7 , Indigo

  3. Android SDK

1. Install Android SDK

Visit this Android
SDK page
, choose which platform and install it.

In Android SDK installed folder, run “Android SDK manager”, choose what
Android version you want to develop.

2. Install ADT Eclipse plugin

To integrate Android SDK with Eclipse IDE, you need to install Eclipse ADT
plugin. Refer to this official guide – “Installing the ADT Plugin“.

In Eclipse IDE, select “Help” -> Install New Software…”, and put below URL
:

https://dl-ssl.google.com/android/eclipse/

Note
In my case, above ADT plugin is taking years to
download, no idea why. If you are facing the similar problem, just download and
install the ADT plugin manually, refer to this ADT plugin troubleshooting guide.

3. Create an Android Virtual Device (AVD)

In Eclipse, you can access the “Android Virtual Device
(AVD)
” in Eclipse toolbar. Click “new” to create a AVD.

Later, Eclipse will deploy the application into this AVD.

4. Create Android Project

In Eclipse, select “File -> New -> Project….”, “Android Project”, and
input your application detail. Eclipse will create all the necessary Android
project files and configuration.

5. Hello World

Locate the generated activity file, and modify a bit to output a string
“Hello World”.

File : HelloWorldActivity.java

package com.mkyong.android;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class HelloWorldActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

TextView text = new TextView(this);
text.setText("Hello World, Android - mkyong.com");
setContentView(text);
}
}

6. Demo


Run it as “Android Application“, see output.

Press “Home” button (on right hand side), and you will noticed that
“HelloWorld” application is deployed successfully on the Android virtual
device.

Note
This tutorial is more to example driven, not much
explanation. For detail and complete explanation, please refer to the
official Android developer hello world tutorial.

Firewall…
In my computer, the COMODO firewall is
installed and blocked the deploying process, caused the connection between
Eclipse ADT and AVD is blocked and failed to deploy. Just make sure your
firewall is configured properly, or just turn it off for Android development
:)

Debug Android application on real device
Sometime,
Android Virtual Device” is not enough to test some real phone
functionalities, like led light, sensor and etc. Then you should refer to
this how
to debug Android application on real device
.

Download Source Code

Download it – Android-HelloWorld.zip (15
KB)

References


    1. Android
      Developers

[Android]Android Hello World Example,布布扣,bubuko.com

时间: 2024-12-30 06:45:51

[Android]Android Hello World Example的相关文章

从零开始学android<android事件的处理方式.二十四.>

在android中一共有 多种事件,每种事件都有自己相对应的处理机制 如以下几种 1 单击事件 View.OnClickListener public abstract void onClick (View v) 单击组件时触发 2 单击事件 View.OnLongClickListener public abstract boolean onLongClick (View v) 长按组件时触发 3 键盘事件 View.OnKeyListener public abstract boolean

[android] android下junit测试框架配置

我们的业务代码一般是放在一个新的包下面,这个业务类不能够通过右键run as java application,因为android项目只能运行在手机上的dalvak虚拟机里面 新建一个包,里面写测试类,测试类需要继承AndroidTestCase类,写测试方法,需要throws exception抛出异常给测试框架,测试方法里面一般new出需测试的类,调用它的方法,然后断言结果,assertEquals(预估, 实际结果) 在outline视窗 (window=>show view=>outl

图解Android - Android GUI 系统

图解Android - Android GUI 系统 (1) - 概论 图解Android - Android GUI 系统 (2) - 窗口管理系统 图解Android - Android GUI 系统 (3) - Surface Flinger (TBD) 图解Android - Android GUI 系统 (4) - Activity的生命周期 图解Android - Android GUI 系统 (5) - Android的用户输入处理

Android Android:persistentDrawingCache

前言 欢迎大家我分享和推荐好用的代码段~~ 声明 欢迎转载,但请保留文章原始出处: CSDN:http://www.csdn.net 雨季o莫忧离:http://blog.csdn.net/luckkof 正文 ViewGroup---属性  android:persistentDrawingCache (Google官方译文) Defines the persistence of the drawing cache. The drawing cache might be enabled by

[Android]Android代码调试工具: Traceview和Dmtracedump

?Android 程序调试工具 Google为我们提供的代码调试工具的亮点:traceview 和 dmtracedump .有了这两个工具,我们调试程序分析bug就非常得心应手了.traceview帮助我们分析程序性能,dmtracedump生成函数调用图.遗憾的是,google提供的dmtracedump是个失败的工具,并不能绘图,本文会详细介绍解决方案,实现绘图. ?生成.trace文件 android.os.Debug类,其中重要的两个方法Debug.startMethodTracing

[Android]Android经典教程

第一季1.Android平台一日游2.搭建Android开发环境3.Say Hello To Android4.Activity初步5.Activity和Intent6.Android当中的常见控件7.Activity生命周期(一)8.Activity生命周期(二)9.Activity布局初步(一)10.Activity布局初步(二)11.Activity布局初步(三)12.Android常见控(二)13.Android常用控件(三)14.Handler的使用(一)15.Handler的使用(二

[Android]Android TraceView工具使用

一. 选择跟踪范围 在想要根据的代码片段之间使用以下两句代码 Debug.startMethodTracing("love_world_"); Debug.stopMethodTracing(); 例如,onCreate与onStart方法之间方法跟踪 public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCr

[Android]Android日志抓取软件测试

1. log文件分类简介 1. 实时打印: 1.1 logcat main(应用程序) -- adb logcat -b main -v time > app.log 1.2 logcat radio(射频相关-SIMSTK,modem相关的ATcommand) -- adb logcat -b radio -v time > radio.log 1.3 logcat events(系统事件的日志,比如触屏事件等) -- adb logcat -b events -v time 1.4 tcp

Android # Android 环境搭建之 Python 配置

在终端输入python,然后import sysprint sys.path The Python Tutorial - Python v2.7.7 documentation https://docs.python.org/2.7/tutorial/index.html Python 3.1.2和2.7比较哪个版本更稳定?_python吧_百度贴吧 http://tieba.baidu.com/p/936048566 python2.7.3和3.3.2的区别_百度知道 http://zhida

[Android]Android布局优化之 merge

转载请标明:转载于http://www.cnblogs.com/Liuyt-61/p/6602915.html ----------------------------------------------------------------- >使用merge合并UI布局 作用:合并UI布局,使用该标签能降低UI布局的嵌套层次 场景(1):布局根结点是FrameLayout且不需要设置background或padding等属性,可用merge代替. 场景(2):某布局作为子布局被其他布局incl