code4app android,How to Write a 'Hello World!' App for Android

Introduction: How to Write a 'Hello World!' App for Android

INTRODUCTION

This tutorial is meant for anyone who has no experience in programming applications for the Android operating system, but would like to. It is very basic, and installing the necessary programs is more complicated than writing the application itself. Once the programs are installed, it should only take a couple minutes to read the tutorial and have your program up and running. The code for this tutorial is explicitly given to you. If you feel like you might be interested in this, you should begin learning the programming language Java. This guide assumes that you have some knowledge of how to install and run programs.

THINGS YOU'LL NEED:

Computer:

Please check that your computer meets the minimum requirements, here .

If it does not, you will not be able to complete the tutorial.

Programs:

Java SE Development Kit 7

Android SDK

Eclipse for your operating system

TIPS AND WARNINGS:

Tip/Warning: Follow the installation instructions exactly

Warning: Cannot run on a Mac, as not all the programs install on a Mac

Add TipAsk QuestionCommentDownloadStep 1: Installing Java SE Development Kit 7

This guide assumes that you know how to install a program, but if you don't, please view this guide.

Install the Java SE Development Kit 7 (JDK for short).

Select "Accept License Agreement" and download the correct executable file for your operating system. If you are using Windows and you do not know what operating system you have, just download the "Windows x86.exe" file.

The JDK is a development environment for building applications, applets, and components using the Java programming language. The JDK includes tools useful for developing and testing programs written in the Java programming language and running on the ava platform. Since Android applications are programmed using the language Java, this program is necessary.

Add TipAsk QuestionCommentDownloadStep 2: Installing the Android SDK

Install the Android SDK just like a normal program, clicking Next and installing it in the location you wish to save it in. Once that it done, find the executable and run the program.

A window will pop up and after it is done loading, you can close the window titled “Choose packages to install.”

On the left side of the Android SDK window, there are 5 options.

Click on the one titled “Available Packages” and click ‘Android Repository.’

For the sake of this tutorial, you should only install "Android SDK Platform Tools, Revision 2" and "SDK Platform Android 2.2, API 8, revision 2."

It is completely possible to complete this tutorial if you have a different SDK Platform installed.

Both of these options can be seen in the picture included with this step.

Click ‘Install Selected’ to install the packages.

Note: If you are prompted to restart your computer after the packages install, do so.

Add TipAsk QuestionCommentDownloadStep 3: Install Eclipse

The last program you need to install is what you will use to do your programming in.

InstallEclipse by downloading the appropriate .zip file and extract the contents to a folder you will remember. Once the contents are extracted, all you need to do isrun the "eclipse.exe" file.

Add TipAsk QuestionCommentDownloadStep 4: Setting Up Eclipse

Finally, we’re ready to get programming. We will be creating an AVD. An AVD is an Android Virtual Device, otherwise known as an emulator.

Open Eclipse .

At the top of the window, click Window -> Android SDK and AVD Manager.

The highlighted section on the left should be highlighting Virtual Devices.

Click the top right button, New , andcreate a new AVD with the same settings as the picture.

When you have filled out the "Name" and selected a "Target," click "Create AVD."

I am using Android 2.2 for this tutorial because that is what my phone uses. It is not the only Target you can write this program on.

Add TipAsk QuestionCommentDownloadStep 5: The Beginning of Your 'Hello World' App

Go back to the Eclipse window and click File -> New -> Project.

Once there, go to the Android folder and select “Android Project,” clicking Next when you have selected it.

Make the appropriate changes to your Project window (as shown in the second picture):

Change the name

Select the target

Name the application

Change the package name

Click Finishwhen you have made the changes.

Add TipAsk QuestionCommentDownloadStep 6: The Guts of the Application

If your screen does not look like the image, navigate over to the left side under HelloWorld and click the arrow to the left of src.

Nowclick the arrow to the left of com.example.helloandroid.

Double click HelloWorldActivity.java and your screen should look the same.

If the code is missing the 3rd line, that’s okay.

Add TipAsk QuestionCommentDownloadStep 7: The Actual Code for Your App

Type the following lines code into the corresponding highlighted lines from the image:

1st Line: import android.widget.TextView;

This line allows you to output text to the screen.

2nd Line: TextView tv = new TextView(this);

This line is necessary if you are going to put out 1 line. In this case, that line is Hello World!

3rd Line: tv.setText(“Hello World!”);

This line (as you can guess) outputs the text Hello World! to the screen.

4th Line: setContentView(tv);

This line goes back to the second line and actually outputs the text to the screen.

With those lines of code, you have successfully created an App to say Hello World!

Add TipAsk QuestionCommentDownloadStep 8: Running Your App

To run the program,right click your HelloWorldproject on the left side.

Move down toRun As and select Android Application .'

The emulator will take a while to open, but it will eventually run your application, so just be patient.

Congratulations, you have now written a successful Hello World application for Android.

For more information on furthering your skills, please see the next step.

Add TipAsk QuestionCommentDownloadStep 9: Further Information

So you want to learn more about making applications for Android? That's great, but nothing you ever create will be as simple as this Hello World application was.

You will need to begin to learn java. Two very good websites are located down below that will help you learn the basics of Java and Android programming. Once you're ready to put an app on the App Store, look here .

This guide was meant to be a stepping stone for those who are interested in programming Android applications in Java. For more info, please visit The Java Tutorials and Android Developers .

Add TipAsk QuestionCommentDownload1 Person Made This Project!

Did you make this project? Share it with us!I Made It!

17 Comments

0

5b04566b31924d5dda8d0bb79d4f85f5.png

vishalc34

4 years ago

ReplyUpvote

Good Tutorial for Beginners

Android Hello World Example

Android Tutorial For Beginners - https://youtu.be/-Cfl6BdLT5K0

149dcd14c01a393417072ae5b8d4faad.png

משהר1

4 years ago

ReplyUpvote

As everybody wrote, all the above information is outdated and wrong. The right answer on the question how to create a "Hello World" android app can be found in this page:0

c602252d2a5f28f22909c0c9af7b0334.png

teiladnam

4 years ago

ReplyUpvote

IMPORTANT NOTE FOR ANYONE CONSIDERING USING THIS: Don't do it! It's out of date. The Eclipse software no longer works with Android.0

149dcd14c01a393417072ae5b8d4faad.png

PhilB82

4 years ago

ReplyUpvote

Where is states:

Open Eclipse .

At the top of the window, click Window -> Android SDK and AVD Manager.

This does not exist as an option.

Is this tutorial perhaps out of date now?0

f027d51a3342f5e070f29e172512adf7.png

DevManiac

4 years ago

ReplyUpvote

It kind of sucks that I have to install all these applications and get all the way to Step 4 of 9 before I find out all the information is wrong, outdated, and unusable! Now I have to uninstall everything and start somewhere else! Terrible for a site that is titled intricutables.com!!!0

149dcd14c01a393417072ae5b8d4faad.png

Camshazam

5 years ago

ReplyUpvote

http://developer.android.com/sdk/index.html

This is like the official Android Developer website. Hopefully people can find info needed here.0

149dcd14c01a393417072ae5b8d4faad.png

ngoel2

5 years ago

ReplyUpvote

Thank you so much bro for the nice article. Before this I learnt this Android Hello world program from here and it was also very good:

http://www.androidtutorialpoint.com/basics/connect...0

717ef2f6154f9a27c8ef48f263948733.png

AlanA50

5 years ago

ReplyUpvote

Sadly these tutorial seems to be out of date, the links to the Android SDK now go to Android Studio and apparently Eclipse is no longer supported by Android. The Elipse page says:

"Open Eclipse .At the top of the window, click Window -> Android SDK and AVD Manager."

....but this doesn't correspond with the options in the latest version of Eclipse0

5eae9f3c6429ccc681e2aba587871d6a.png

sharpstringer

5 years ago

on Introduction

ReplyUpvote

Make your first Android App - http://rowanstringer.com/your-first-android-app/

ce990b72d3115886e0fac9bb50c6cd7b.png0

673d4a3d765ef858d00deccb8ae8c596.png

yaalshu.

5 years ago

on Introduction

ReplyUpvote

Using Eclipse from the link provided, there is nothing that has to do with Android. No Android SDK, AVD, Project, etc. HELP??0

673d4a3d765ef858d00deccb8ae8c596.png

yaalshu.

5 years ago

on Introduction

ReplyUpvote

Using Eclipse from the link provided, there is nothing that has to do with Android. No Android SDK, AVD, Project, etc. HELP??0

149dcd14c01a393417072ae5b8d4faad.png

pjtrowe

6 years ago

on Introduction

ReplyUpvote

Check out my blog. It provides a video to show you how to create your first Android Hello World app.

http://androidprogrammeringcorner.blogspot.com/2015/02/pak-longs-programming-corner-for.html

Best regards,

Philip0

8e8fb2ab3b4a5b645c5c37099042ac5a.png

KumananA

6 years ago

on Introduction

ReplyUpvote

http://okayfiles.com/file/0x864r0

8e8fb2ab3b4a5b645c5c37099042ac5a.png

KumananA

6 years ago

on Introduction

ReplyUpvote

http://okayfiles.com/file/0x864r0

149dcd14c01a393417072ae5b8d4faad.png

MichelleD1

6 years ago

on Introduction

ReplyUpvote

I used SDK manager to install Android 4.0 and I try to compile. There is source Activity java and no errors at all, but emulator shows Android login screen and nothing happens. Weird.0

149dcd14c01a393417072ae5b8d4faad.png

diy_bloke

7 years ago

on Step 4

ReplyUpvote

interesting, but before I can even try anything I have to figure out how to 'launch' eclipse on ubuntu. Whatever icon i click, nothing happens, except when I click 'eclipse': then a file in my bowser goes to another place.

Seriously thinking about going back to windows0

7285b08dc8a062d1aa9f2cfe85fba54b.png

CrLz

9 years ago

on Introduction

ReplyUpvote

Many thanks for sharing!Post Comment

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值