You are on page 1of 30

CHAPTER 5

GETTING STARTED WITH ANDROID


CONTENT :

 Deciding to target Android as your mobile


platform
 Getting the tools you need to develop Android
 Creating a new project
 Creating the Derby project in Android
ANDROID HISTORY :

 Android Inc. was initially started in 2003, out


of a frustration with the smartphone market
as it existed at the time. It was acquired by
Google in 2005.

 The hardware side of Android is supported by


the Open Handset Alliance (OHA), which is a
conglomeration of many handset
manufacturers, and the software is
maintained by the Android Open Source
Project, which is led by Google.
CONT….

 when researching Android you may come across


the name Dalvik. It is the virtual machine that
runs on the Android device, and your applications
run within it.

 What does this mean to developers?


When your applications run inside this virtual
space, it provides a level of security to the base OS. Also,
Dalvik has been designed with performance in mind.
As of Android 2.2 it also provides just-in-time
compilation to your apps (because) Dalvik requires specially
compiled .dex files and not just the standard .class files
generated in a normal Java compilation).
WHY TARGET ANDROID?

 Identifying an application that exists on another


platform
 but does not exist on Android is a good reason to
target Android
 we should do some research.
because developer has targeted iOS or
BlackBerry as the primary platform, you have to
assume it needs information than other platform
 But Android is a potentially on the horizon
platforms in marketing
WHO SUPPORTS ANDROID?

 HTC, LG, Motorola, and Samsung are the


major players in the Android smartphone
market.
 Archos, Dell, Samsung, and Toshiba hold the
largest pieces of the Android tablet market.

You should note that Amazon’s


Kindle Fire and Nook Colour are up-and-comers
and use a customized version of the Android
tablet (Version 3) OS on their devices.
Android As Competition To Itself :

 Android was designed to be run on many different types


of devices, created by many different manufacturers (as
opposed to the closed system that Apple has maintained)
 Google’s Android Operating System and the introduction
of the mobile HTC 1.
 Apple and their line of iPhone Smartphones (iPhone 4,
iPhone 4S, iPhone 5) have long been considered the top
Smartphone in the Mobile Industry due to the user-
friendly interface and vast variety of mobile application
on their iOS Mobile
 Application Market place shifts in popularity, Apple,
Windows and Blackberry might be taking a step
backward as Google takes steps forward.
 the open nature of Android OS is a commonplace for
manufacturers to create vendor-specific builds of Android, and
when this happens you are beholden to them for OS updates
Some issues:
 You have another hurdle to cross when releasing your
application for sale to the public because some devices may
not be able to purchase it because of these limitations.
 Another issue that has cropped up is the lack of over-the-air
(OTA) distribution of OS updates by cellular carriers. Often
your device is perfectly capable of running a later version of
the Android software, but carriers are often slow to distribute
that to their customers.
Multiple Markets and Market Locks:

 Depending on your version of Android, and


depending on the manufacturer of a given device.
 we may find yourself locked into using a vendor-
specific Android marketplace. Additionally,
application vendors can list their application not
only on Google Play or vendor-specific
marketplaces, but also on the Amazon App Store.
Getting The Tools You Need:
In this we going to learn how to install and
instructions from the Android Developer section
What You Need to Begin:
 Because Android applications run within the Dalvik VM, you
can write them on any platform that supports the developer
tools. This currently includes the following:
 Microsoft Windows (XP or later)
 Mac OS X 10.5.8 or later (Intel chips only)
 Linux (including GNU C Library 2.7 or later)
 To get started, you’ll need to download and install the
following:
 The Android SDK starter package
 Java Development Kit (JDK) 5 or 6
You can download the latest JDK from Sun at
http://java.sun.com/javase/downloads/index.jsp.
Downloading and Installing JDK:

 The first thing that you need to do to develop


Android applications is to visit

http://www.oracle.com/technetwork/java/javas
e/downloads/index.html
 And ensure that you have the Java JDK
installed.
The JDK is the Java Development Kit. You need this package to do any Java
development on your machine, Android or otherwise. Be sure to look for the
Java Platform, Standard Edition JDK.
Downloading and Installing Android studio:

 Download Android Studio


• From http://developer.android.com/sdk/installing/index.html
 System Requirements for Windows
• Microsoft® Windows® 8/7/Vista (32 or 64-bit)
• 4 GB RAM minimum, 8GB RAM recommended
• 500 GB hard disk space
• At least 1 GB for Android SDK, emulator system images, and
caches
• 1280 x 800 minimum screen resolution
• Java Development Kit (JDK) 8
• Optional for accelerated emulator: Intel® processor with
support for Intel® VT-x, Intel® EM64T (Intel® 64), and Execute
Disable (XD) Bit functionality

Downloading and Installing the Android SDK:


 After you have installed the Android studio, you need to install the Android Software
Developer Kit (http://developer.android.com/sdk/index.html). This includes all the
tools necessary to build.
Installation process
Need to check the components, which are required to
create applications, below the image has selected Android
Studio, Android SDK, Android Virtual Machine
Installing Additional SDK Components

 The last step in preparing your development


environment for Android is to download additional
Android OS packages.
 This enables you to build applications that target that
OS, and also gives you the tools you need to emulate a
device running that OS on which to test all of your
applications , whether or not they have been targeted
to that OS version
Opening new project:-
you must get finish button and it gonna be open android studio
project with Welcome to android studio message as shown below
Selecting a new project:-
At the final stage it going to be open development tool to
write the application code.
Create Android Virtual Device:-To test your Android applications,
you will need a virtual Android device. So before we start writing our code,
let us create an Android virtual device. Launch Android AVD Manager
Clicking AVD Manager icon as shown below
After Click on a virtual device icon, it going to be shown by
default virtual devices which are present on your SDK, or else
need to create a virtual device by clicking Create new Virtual
device button
 After installing virtual devices
 We can type your coding (or)program in
the device to design the application (app)
 By having default program HELLO WORLD
we can RUN automatically the program by
using DROP AND DOWN Method for easy
accessing
 Android Basics:-
 You have two options for starting your application. You can build the layout you would like to
populate, or you can build the code that will populate the layout. Either is acceptable; it just
depends on what you feel most comfortable with.

Creating User Interfaces:-


 This section describes the common widgets that come with Android, and shows examples of the
different layout elements you can use to coordinate the flow of your application’s activities.

Basic Android UI Elements:-


 All of the basic elements in Android are stored in the android . widgets namespace
in the SDK . The most commonly used elements include:
 Button: This is a standard button element.
 <Button
android:layout_height=”wrap_content”
android:layout_width=”wrap_content”
android:id=”@+id/button”
android:text=”Click Me”
android:onClick=”btnClick” />
 Code: This code is necessary to handle the Click event noted in the XML layout.
 public void btnClick (View view) {
}
 Text View: When I see this I want to think text box, but it isn’t a text box.
Text View is effectively the same as a label in other languages. It is just a
place to display text.
 Layout: <TextView
android: id=”@+id/textview”
android:layout_width=”fill parent”
android:layout_height=”fill parent”
android: text=”Hello World”/>
 Code:
TextView tvToShow = (TextView)this.findViewById(R.id.textview);
tvToShow.setText(“Ta-Dah!”);
 ➤ Edit Text: This is the text box widget. You can edit the contents of the
text box and save those values in code
 Layout:
<EditText

android: id=”@+id/txtUsername”

android: hint=”Username”

android:layout_width=”fill_parent”

android:layout_height=”wrap_content” />

Code:
EditText txtUserName = (EditText) findViewById(R.id.txtUsername);

String username = txtUserName.getText().ToString();

➤ Checkbox: This is a standard checkbox element.

Layout:

<Checkbox android: id=”@+id/checkbox”

android:layout_width=”wrap_content”

android:layout_height=”wrap_content”

android: text=”Checkbox Text” />

Code:
final CheckBox checkbox = (CheckBox) findViewById(R.id.checkbox);

checkbox.setOnClickListener(new OnClickListener() {

public void onClick(View v) {

if (((CheckBox) v).isChecked()) {

//It’s Checked

}
if (((CheckBox) v).isChecked()) {
//It’s Checked
}
else {
//Not Checked
}
}
});
Code:
final CheckBox checkbox = (CheckBox) findViewById(R.id.checkbox);
checkbox.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
if (((CheckBox) v).isChecked()) {
//It’s Checked
}
else {
//Not Checked
}
}
});
 And some of the codes like Radio Button , list view , linear layout ,relative layout ,
table layout
 CONNECTING TO THE GOOGLE PLAY:-
 This section explains what is necessary to publish your application to the
Google Play and which has other requirements like Amazon Android
Marketplace,. But it may be more of a marketing choice than a development
choice, we decided to go with the explanation of the basic Google Play
distribution process.
Getting an Android Developer Account:-
 Signup is a snap for a dev account. Just make sure you have a Google
account (Gmail, or Google Apps), $25 (one-time registration fee), head to
https://play.google.com/apps/publish/signup, and you are all set.
 Signing Your Application:-
 Signing your application with Eclipse is a relatively simple process:
 1. Right-click your project in the Package Explorer and select File ➪ Export.
 2. Select Export Android Application.
 3. Complete the steps of the wizard and you will have a key store, and a
signed release build of your app ready for the market.
 When you have created your key store, make sure to guard it safely. It is the
file you will use to sign your application every time you update, and if you
lose it you cannot upgrade your application in Google Play.
ANDROID DEVELOPMENT PRACTICES:-
This section covers the fundamentals of developing an Android application, explaining
the permissions in the Manifest and how you must always manage your navigation between Activities using the
back stack

Android Fundamentals: When developing an Android app you need to account for which of the four basic
components (Activities, Services, Content Providers, and Broadcast Receivers) of apps you need to include..

 Activities:-
Activities are the individual screens in your application. All of the functionality that is
exposed in the UI for that screen lives in the scope of that Activity.

 Services:-
Services are components that run in a background thread. Common usages for services
are to hold long-running processes, or for functions that can happen in parallel with the application (playing music
from your library, or updating a web service). Be aware that when you have an application running in the
background it can take processing power from the device, though contrary to popular thought it does not affect
your battery life.

 Content Providers:-
Content providers are interfaces to the offline storage that you have within your app. If
you create a suite of applications you may want to have a single point for holding all of your data. You can also
leverage the Content Providers built into the Android OS. The standard set of providers in the OS allows you to get
content from the Calendar, Contacts, Media Store, Messaging, and Voice Mail applications.

 Broadcast Receivers:-
Broadcast receivers are components that respond to system messages. You would use a
Broadcast Receiver to catch events like the screen turning off, or the battery reaching a critical level. A common
use for a Broadcast Receiver is for querying the status of the network (Wi-Fi or cellular) so that you can display
the appropriate messaging to the user.

You might also like