Top Banner
Build Your Android App in 7 Easy Steps www.mobilepundits.com
12

Android app tutorial

Apr 06, 2016

Download

Documents

alva christi

Android phones can run many applications, it means you can browse, any site lets say facebook while listened to the song.It is the most popular platform and many companies are also moving towards outsourcing Android apps development.
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Android app tutorial

Build Your Android App in 7 Easy Steps

www.mobilepundits.com

Page 2: Android app tutorial

Build your first Android App in 7 simple steps

Overview of Android

Mobile application development is the hottest thing and in boom in the programming world right

now. The two most popular mobile platforms which are most commonly used these days are

Android and iOS (Apple). Although the numbers tend to fluctuate frequently, it seems that

Android has taken the top spot from Apple.

Android is an open source platform and Linux-based Operating System for mobile devices such

as Smartphone’s and tablet computers. Android application development is in great demand

these days. It provides a rich application framework that allows you to build highly innovative

apps and games for mobile devices in a Java language environment.

If the overall ratio is to be compared then the demand for Android is much higher. In the United

States, at least 50% of all Smartphone users are having Android devices. Globally, almost 70%

of people uses Android. It is the most popular platform from where you could start building your

android apps.

Not only is Android popular, but it could also become a very profitable platform for users once

you start creating your own apps. Many companies are also moving towards outsourcing

Android apps development.

Building Your First App

Before you start with the class make sure that you have development environment set up. For

this follow the below steps as shown:

Page 3: Android app tutorial

1. Download the Android SDK.

2. Install the ADT plugin for Eclipse (if you are using the Eclipse IDE).

3. Download the latest SDK tools and platforms using the SDK Manager.

Create Your Android Project with the help of Eclipse

In Eclipse, create a new Android project and name it as shown:

1. Click New in the toolbar.

2. In the window that appears, open the Android folder, select Android Application

Project, and click on Next button.

The New Android App Project wizard in Eclipse.

Below are the details of the form:

Page 4: Android app tutorial

Application name - The user-friendly name of the application that will be

displayed in the Applications tab of the Android UI. For this project, use "My

First App."

Project name - The name of the project you need to enter in it.

Package name - The name of the package. This name will be used as the package

name in your Java files. Package name must be fully qualified. The convention is

to use your company's domain name in reverse order.

Minimum Required SDK is the lowest version of Android that your app

supports. To support as many devices as possible, you should set this to the lowest

version available that allows your app to provide its core feature set.

Target SDK indicates the highest version of Android

As new versions of Android become available, while testing your app prefer the

new version in order to take advantage of new platform features.

Compile With is the platform version against which you will compile your app.

By default, this is set to the latest version of Android available in your SDK. You

can also build your app in the lower version but it will not contain new features

and if you prefer the latest version it will give your app the latest user experience

with new and innovative features.

Theme specifies the Android UI style to apply for your app. You can also leave it

blank also. These themes are nothing but some pre defined color schemes, which

you can use to improve your application's User Interface.

Click Next.

3. On the next screen to configure the project, leave the default selections and click

Next. The screen will appear as shown below:

Page 5: Android app tutorial

If you have checked the create custom launcher check box, next screen will be for the creation

of launcher icon.

4. The next screen can help you create a launcher icon for your app.

5. You can customize an icon in several ways and the tool generates an icon for all screen

densities.

Page 6: Android app tutorial

On this screen, you can configure different options to create a launcher icon. You can choose

your own image, Text or even your clip-arts. In the Right pane, you can see the demo of the icon

Click Next.

6. Now you can select an activity template from which to begin building your app.

Blank Activity: This will create a blank activity with just 1 textview.

Full Screen Activity: This is typically used for games. This activity hides the status bar

and then your activity takes all screen space.

Master Detail Flow: This template creates advanced navigation, based on fragments,

which will work on tablets and phones as well without any change.

Page 7: Android app tutorial

For this project, select Blank Activity and click on Next button.

Page 8: Android app tutorial

7. Leave all the details for the activity by default and click Finish.

Your Android project is now a basic "Hello World" app that contains some of the default files.

To run the app see the next section as mentioned below:

Running Your App

If you followed the previous lesson to create an Android project, it includes a default set of

"Hello World" source files that allow you to immediately run the app.

How you run your app depends on two things: whether you have a real Android-powered device

and whether you're using Eclipse. This lesson shows you how to install and run your app on a

real device with either Eclipse or the command line tools.

Page 9: Android app tutorial

Before running an app, you must be aware about the few files and directories that will be helpful

while creating the Android project:

AndroidManifest.xml

The AndroidManifest.xml file is an application configuration file that contains detailed

information about your application, such as the number of activities you have in your

application, the version information of your application, the types of permissions your

application needs, and so on. Here you will learn about the various declarations in a file.

One of the most important elements your manifest should include is the <uses-sdk> element.

This declares your app's compatibility with different Android versions using the android:

minSdkVersion and android: targetSdkVersion attributes. For your first app, it should look

like this:

You should always set the android: targetSdkVersion as high as possible and test your app on

the corresponding platform version.

src/

Directory for your app's main source files. By default, it includes an Activity class that runs

when your app is launched using the app icon.

res/

Contains several sub-directories .Some of them are mentioned here:

drawable-hdpi/

Directory for drawable objects (such as bitmaps) that are designed for high-density (hdpi)

screens. Other drawable directories contain assets designed for other screen densities.

layout/

Directory for files that define your app's UI.

Page 10: Android app tutorial

When you build and run the default Android app, the default Activity class starts and loads a layout file

that says "Hello World." Through this you will understand how to run your app before start developing

it.

Run on a Real Device

If you have a real Android-powered device, here are the below steps so that you can install and

run your app easily:

1) Plug in your device to your development machine with a USB cable. If you're developing

on Windows, you might need to install the appropriate USB driver for your device.

2) Enable USB debugging on your device.

On most devices running which are following the android older version such as 3.2 or

older you will get the option under Settings > Applications > Development.

In Android 4.0 or the latest version you will get the option under Settings > Developer

options.

Note: On Android 4.2 and in the newer version, Developer options are hidden by

default. To make it available, follow the steps as shown:

Go to Settings > About phone and tap Build number seven times. Return to the

previous screen to find Developer options.

To run the app from Eclipse:

1. Open one of your project's files and click Run from the toolbar.

2. In the Run as window that appears, select Android Application and click on OK

button. Your app will now be deployed on your device. It will look as below if deployed

in an AVD. (Android Virtual Device)

Page 11: Android app tutorial

Eclipse will install the app on your connected device and starts it accordingly.

Or

There is another method too. You can run your app from a command line:

1. Change directories to the root of your Android project and execute:

ant debug

2. Make sure the Android SDK platform-tools/ directory is included in your PATH

environment variable, then execute:

adb install bin/MyFirstApp-debug.apk

3. On your device, locate MyFirstActivity and open it.

Page 12: Android app tutorial

That's how you can build and run your Android app on a device successfully.