Professional Documents
Culture Documents
Android Development Day 2
Android Development Day 2
Android Development Day 2
Day - 2
1
Agenda
Session 1
Introduction to Android Stack
How to Set-Up Development Environment
Setup JDK
Setup Eclipse
Setup Android SDK and Emulator/s
Session 2
Practically set-up the dev-environment
Running a Hello Android Program
Understanding different components of Hello Android
Android Software Development
3
Android Architecture
4
Application Framework
Developers
can build extremely rich and innovative
applications
have full access to framework APIs
5
Application Framework
6
Application Components
no main() function
There are four types of components:
Activities
Services.
Broadcast Receivers
Content providers
7
Types of Android Applications
Foreground Apps
Background
Services and intent receivers
Intermittent
Widget
Developing for Mobile
Hardware imposed design consideration
Low processing power
Limited RAM
Limited storage
Small Screen
High costs of use
Slow data rates
Unreliable Data connection
Limited Battery Life
Mobile Development
Best Practices
Try your best to accommodate the limitations
Be prepared for unreliability
Expect low speeds and high latency
Keep the costs low wherever possible
Make seamless and easy UIs
Android Development Philosophy
Android design philosophy expects apps are designed
for:
Performance
Responsiveness
Seamlessness
Security
Development Kickstart
Step 1 – Downloads:
JDK 5 or 6
http://www.oracle.com/technetwork/java/javase/downl
oads/index.html
Eclipse
http://www.eclipse.org/downloads/
Andriod SDK
http://developer.android.com/sdk/
12
Development Kickstart
Step 2: Install and unzip
13
Development Kickstart
Step 3 – Configure Eclipse and SDK
This includes
Configure Eclipse Plugin for Android
Configure SDK with Eclipse
14
Downloading
Download JDK
Download SDK
Download Eclipse
Configuring Dev Environment
Install JDK
Unzip Eclipse
Add Eclipse Plugin,
How?
Adding Eclipse Plugin
Goto Help Menu
Click Install
Software
Configuring Eclipse
Type following URL
https://dl-ssl.google.com/android/eclipse
Press Add
Wait for the components to load
Select all checkboxes and install the software
Configure Android SDK
19
And you are ready to develop
Lets make a
Hello Android
.........
21
Understanding Hello Example
package com.test9;
import android.app.Activity;
import android.os.Bundle;
22
Package and Imports
package com.test9;
import android.app.Activity;
import android.os.Bundle;
23
Activity
24
onCreate over-ride
25
Where did the Hello string come from?
setContentView(R.layout.main);
26
Layout
Layouts can be defined in two ways:
27
Main.xml for Hello Project
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
</LinearLayout>
28
Understanding Layout XML
XML defines which layout you are using
LinearLayout being used right now (we will see other
layouts later)
XML tells you which components to add to the screen,
for examole:
Buttons
Text boxes and text areas
List boxes etc
What does the XML say?
Benefits?
Users can work in parallel developing the UI xml and
code.
Resource Types
="@string/hello”
Creating the same layout via code
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LinearLayout.LayoutParams lp;
lp = new
LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT);
LinearLayout.LayoutParams textViewLP;
textViewLP = new
LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT);
LinearLayout ll = new LinearLayout(this);
ll.setOrientation(LinearLayout.VERTICAL);
ll.addView(myTextView, textViewLP);
this.addContentView(ll, lp);
}