SlideShare une entreprise Scribd logo
1  sur  37
Android
Development
Made EasyW I t h S a m p l e P r o j e c t
Outline:
 Overview on Android
 Installing ADT on Eclipse
 Explore Project Components
 Sample Project
Android is an open mobile phone platform that was
developed by Google and later by Open Handset
Alliance. Google defines Android as a "software
stack" for mobile phones.
Software stack is made up of operating system(the
platform on which everything runs), the middleware
(the programming that allows applications to talk to
a network and to one another) and the applications
(the actual programs that phone will run)
July 2005 - Google Inc. bought from Danger Inc
Open Handset Alliance was formed headed by Google
which is composed of companies like Intel, T-
Mobile, Spring Nextel and more.
In 2008, Android became available as an open source
and ASOP(Android Open Source Project) is
responsible for maintaining and development of
android.
February 2009, the first android version was released,
Android 1.1. for Mobile G1.
 Android 1.1
 Android 1.5 Cupcake
 Android 1.6 Donut
 Android 2.0/2.1 Eclair
 Android 2.2.x Froyo
 Android 2.3.x Gingerbread
 Android 3. x Honeycomb
 Android 4.0.x Ice Cream Sandwich
 Android 4.1 Jelly Bean
Note: When developing an application, consider the market share of the android version. The
higher the market share, the higher number your target market is.
Note: Based on my development experience, ADT can run on at least Dual Core with at
least 2GB RAM.
Please refer to:
www.developershaven.net
Activity
• Present a visual user interface for one focused endeavor the user can undertake
• Example: a list of menu items users can choose from
Services
• Run in the background for an indefinite period of time
• Example: calculate and provide the result to activities that need it
Broadcast Receivers
• Receive and react to broadcast announcements
• Example: announcements that the time zone has changed
Content Providers
• Store and retrieve data and make it accessible to all applications
• Example: Android ships with a number of content providers for common
Intents
• Hold the content of a message
• Example: convey a request for an activity to present an image to the user or let
the user edit some text
public class CCSActivity extends Activity {
/** Called when the activity is first created.
*/
@Override
public void onCreate(Bundle
savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
 Run in the background
 Can continue even if Activity that started it dies
 Should be used if something needs to be done while the
user is not interacting with application
 Otherwise, a thread is probably more applicable
 Should create a new thread in the service to do work in,
since the service runs in the main thread
 Can be bound to an application
 In which case will terminate when all applications bound to
it unbind
 Allows multiple applications to communicate with it via a
common interface
 Needs to be declared in manifest file
 Like Activities, has a structured life cycle
SRC
• The project source code
GEN
• Auto generated code
• Example: R.java
Included libraries
Resources
• Drawables
• Layout
• Values like strings
Manifest File
• A must have xml file. Contains essential information about the
system to the android system
 Auto-generated: you shouldn’t edit it
 Contains IDs of the project resources
 Enforces good software engineering
 Use findViewById and Resources object to get
access to the resources
 Ex. Button b = (Button)findViewById(R.id.button1)
 Ex. getResources().getString(R.string.hello));
 Eclipse has a great UI creator
 Generates the XML for you
 Composed of View objects
 Can be specified for portrait and landscape
mode
 Use same file name, so can make completely
different UIs for the orientations without
modifying any code
 Click ‘Create’ to make layout modifications
 When in portrait mode can select ‘Portrait’ to
make a res sub folder for portrait layouts
 Likewise for Landscape layouts while in landscape mode
 Will create folders titled ‘layout-port’ and ‘layout-land’
 Note: these ‘port’ and ‘land’ folders are examples
of ‘alternate layouts’, see here for more info
 http://developer.android.com/guide/topics/resources/providing-
resources.html
 Avoid errors by making sure components have the
same id in both orientations, and that you’ve
tested each orientation thoroughly
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/ap
k/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
android:id="@+id/tv_hello"/>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Large Text“
android:textAppearance="?android:attr/textApp
earanceLarge"/>
</LinearLayout>
res/values/string.xml
1. Lunching a new activity without expecting without expecting a result
2. Lunching a new activity and expecting a result when it finished.
CalledActivity.class
 On Eclipse IDE. Go To File >
New > Project > Android
Project
 See image at the side for the
prompt that appear. Click
next button.
 Select android version.
Tip: select the latest OS
version available. You can
add minimum and target SDK
on your manifest file to
support earlier android
versions.
 Provide package name of
your project. Valid package
name consist of two names
separated by a period.
 Provide package name of
your project. Valid package
name consist of two names
separated by a period.
 Optional: Change minimum
SDK for the lowest android
version your application will
support.
 Hit on finish
 Under res/layout on your
project explorer. Open
main.xml. Create a layout
like this:
In main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button1" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 2" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 3" />
</LinearLayout>
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10" >
<requestFocus />
</EditText>
</LinearLayout>
 Under res/values on your
project explorer. Open
strings.xml.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, SampleProjectActivity!</string>
<string name="app_name">SampleProject</string>
<string name="button1">Button 1 Clicked.</string>
</resources>
NOTE: string with name button1 is being referenced by Button 1 android:text property.
See main.xml in your layout.
 Under SRC on your project
explorer. Open
SampleProjectActivity.java.
Change code to this:
 See comments for better
understand.
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import
android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class SampleProjectActivity extends Activity implements OnClickListener{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Toast.makeText(this, "Hello.", Toast.LENGTH_LONG).show();
//referencing components in our layout as set in setContentView, - main.xml
//findViewById is used hence we components in our layout will be called
//through their ids as set in android:id properties. See main.xml in your layout.
Button btn1 = (Button)findViewById(R.id.button1);
//one way in handling click event
btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//Toast is a prompt that will notify user of what has happened in the
application
//but not requiring user an action.
Toast.makeText(getApplication(), "Button 1 Clicked",
Toast.LENGTH_LONG).show();
}
});
Button btn2 = (Button)findViewById(R.id.button2);
Button btn3 = (Button)findViewById(R.id.button3);
//Other way of handling event inside an activity
btn2.setOnClickListener(this);
btn3.setOnClickListener(this);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch(v.getId())
{
case R.id.button2:
EditText editText = (EditText)findViewById(R.id.editText1);
editText.setText("Button 2 Clicked!");
break;
case R.id.button3:
// Intent with out waiting for result.
// This is creating a new view and passing the new controll to the next view.
Intent intent = new Intent(this, NextActivity.class);
startActivity(intent);
break;
}
}
}
 Create NextActivity.java
 Right click SRC folder > New
> Class.
 Change code to this:
import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;
public class NextActivity extends Activity{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// you can have a new layout. but for this example
// we will be reusing the main.xml as our layout.
// we will just manipulate the text to inform user that
//a new activity has been created.
setContentView(R.layout.main);
// setTitle - change the title of the next view
setTitle("Next Activity");
//setting page title
TextView pageTitle =
(TextView)findViewById(R.id.pagetitle);
pageTitle.setText("Hello, You are now in the Next
Activity Class.");
Button btn1 = (Button)findViewById(R.id.button1);
btn1.setText("Option 1");
Button btn2 = (Button)findViewById(R.id.button2);
btn2.setText("Option 2");
Button btn3 = (Button)findViewById(R.id.button3);
btn3.setText("Option 3");
}
}
 Open Manifest.xml in your
project explorer.
 Register NextActivity class to
your project.
 Your new manifest file must
look like the code at the
side.
 Save all the changes
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/re
s/android"
package="com.sample"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8"
android:targetSdkVersion="15"/>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".SampleBradActivity"
android:label="@string/app_name" >
<intent-filter>
<action
android:name="android.intent.action.MAIN" />
<category
android:name="android.intent.category.LAUNCHE
R" />
</intent-filter>
</activity>
<activity
android:name=".NextActivity"
android:label="@string/app_name" />
</application>
</manifest>
 Right click your project name in your project explorer > RUN AS
> ANDROID APPLICATION.
 Emulator will boot up. Wait until home screen is shown.
 Your application will be displayed on the screen.
 You can now enjoy the application.
Congratulations!!!
 Installation: http://developershaven.net
 Google API: http://mfarhan133.wordpress.com/2010/10/01/generate-google-maps-api-key-for-android/
 Android Developer’s Website : http://developer.android.com/index.html
 Numerous Forums & other developer sites, including:
 http://www.javacodegeeks.com/2011/02/android-google-maps-tutorial.html
 http://efreedom.com/Question/1-6070968/Google-Maps-Api-Directions
 http://stackoverflow.com
 http://www.anddev.org/google_driving_directions_-_mapview_overlayed-t826.html
THANK YOU !!!

Contenu connexe

Tendances (20)

Android tutorial
Android tutorialAndroid tutorial
Android tutorial
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorial
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorial
 
Android session 1
Android session 1Android session 1
Android session 1
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorial
 
Android apps development
Android apps developmentAndroid apps development
Android apps development
 
Ppt 2 android_basics
Ppt 2 android_basicsPpt 2 android_basics
Ppt 2 android_basics
 
Android Basic Components
Android Basic ComponentsAndroid Basic Components
Android Basic Components
 
Android UI Fundamentals part 1
Android UI Fundamentals part 1Android UI Fundamentals part 1
Android UI Fundamentals part 1
 
Android gui framework
Android gui frameworkAndroid gui framework
Android gui framework
 
What is Android?
What is Android?What is Android?
What is Android?
 
Android In A Nutshell
Android In A NutshellAndroid In A Nutshell
Android In A Nutshell
 
Training android
Training androidTraining android
Training android
 
Android Development in a Nutshell
Android Development in a NutshellAndroid Development in a Nutshell
Android Development in a Nutshell
 
Android Components
Android ComponentsAndroid Components
Android Components
 
Android architecture
Android architecture Android architecture
Android architecture
 
Android dev o_auth
Android dev o_authAndroid dev o_auth
Android dev o_auth
 
Day 4: Android: Getting Active through Activities
Day 4: Android: Getting Active through ActivitiesDay 4: Android: Getting Active through Activities
Day 4: Android: Getting Active through Activities
 
04 activities - Android
04   activities - Android04   activities - Android
04 activities - Android
 
Day 4: Android: UI Widgets
Day 4: Android: UI WidgetsDay 4: Android: UI Widgets
Day 4: Android: UI Widgets
 

En vedette

Game design for beginners
Game design for beginnersGame design for beginners
Game design for beginnersMinhaj Kazi
 
My sql essentials
My sql essentialsMy sql essentials
My sql essentialsMinhaj Kazi
 
Unreal gaming design kit basic concepts
Unreal gaming design kit  basic conceptsUnreal gaming design kit  basic concepts
Unreal gaming design kit basic conceptsMinhaj Kazi
 
Android development-workshop-v2-1228043706544191-8
Android development-workshop-v2-1228043706544191-8Android development-workshop-v2-1228043706544191-8
Android development-workshop-v2-1228043706544191-8Minhaj Kazi
 
Extracts from Game Design Document
Extracts from Game Design DocumentExtracts from Game Design Document
Extracts from Game Design DocumentMichael Crosby
 
Study: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsStudy: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsLinkedIn
 

En vedette (8)

Game design for beginners
Game design for beginnersGame design for beginners
Game design for beginners
 
My sql essentials
My sql essentialsMy sql essentials
My sql essentials
 
Unreal gaming design kit basic concepts
Unreal gaming design kit  basic conceptsUnreal gaming design kit  basic concepts
Unreal gaming design kit basic concepts
 
Design Document
Design DocumentDesign Document
Design Document
 
Intro to my sql
Intro to my sqlIntro to my sql
Intro to my sql
 
Android development-workshop-v2-1228043706544191-8
Android development-workshop-v2-1228043706544191-8Android development-workshop-v2-1228043706544191-8
Android development-workshop-v2-1228043706544191-8
 
Extracts from Game Design Document
Extracts from Game Design DocumentExtracts from Game Design Document
Extracts from Game Design Document
 
Study: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsStudy: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving Cars
 

Similaire à Android Development project

Industrial Training in Android Application
Industrial Training in Android ApplicationIndustrial Training in Android Application
Industrial Training in Android ApplicationArcadian Learning
 
Lec005 android start_program
Lec005 android start_programLec005 android start_program
Lec005 android start_programEyad Almasri
 
Synapseindia android apps introduction hello world
Synapseindia android apps introduction hello worldSynapseindia android apps introduction hello world
Synapseindia android apps introduction hello worldTarunsingh198
 
Android Tutorial For Beginners Part-1
Android Tutorial For Beginners Part-1Android Tutorial For Beginners Part-1
Android Tutorial For Beginners Part-1Amit Saxena
 
Android Workshop
Android WorkshopAndroid Workshop
Android WorkshopJunda Ong
 
Android application development
Android application developmentAndroid application development
Android application developmentslidesuren
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android DevelopmentAly Abdelkareem
 
Android Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_androidAndroid Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_androidDenis Minja
 
Native Android Development Practices
Native Android Development PracticesNative Android Development Practices
Native Android Development PracticesRoy Clarkson
 
Android terminologies
Android terminologiesAndroid terminologies
Android terminologiesjerry vasoya
 
Answer1)Responsive design is the idea where all the developed pag.pdf
Answer1)Responsive design is the idea where all the developed pag.pdfAnswer1)Responsive design is the idea where all the developed pag.pdf
Answer1)Responsive design is the idea where all the developed pag.pdfankitcomputer11
 

Similaire à Android Development project (20)

Industrial Training in Android Application
Industrial Training in Android ApplicationIndustrial Training in Android Application
Industrial Training in Android Application
 
Android Intro
Android IntroAndroid Intro
Android Intro
 
Lec005 android start_program
Lec005 android start_programLec005 android start_program
Lec005 android start_program
 
Android TCJUG
Android TCJUGAndroid TCJUG
Android TCJUG
 
Synapseindia android apps introduction hello world
Synapseindia android apps introduction hello worldSynapseindia android apps introduction hello world
Synapseindia android apps introduction hello world
 
Android Tutorial For Beginners Part-1
Android Tutorial For Beginners Part-1Android Tutorial For Beginners Part-1
Android Tutorial For Beginners Part-1
 
Android Workshop
Android WorkshopAndroid Workshop
Android Workshop
 
Android Development Basics
Android Development BasicsAndroid Development Basics
Android Development Basics
 
Android application development
Android application developmentAndroid application development
Android application development
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorial
 
Google Android
Google AndroidGoogle Android
Google Android
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android Development
 
Android-Tutorial.ppt
Android-Tutorial.pptAndroid-Tutorial.ppt
Android-Tutorial.ppt
 
Android
AndroidAndroid
Android
 
PPT Companion to Android
PPT Companion to AndroidPPT Companion to Android
PPT Companion to Android
 
Android Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_androidAndroid Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_android
 
Native Android Development Practices
Native Android Development PracticesNative Android Development Practices
Native Android Development Practices
 
Android terminologies
Android terminologiesAndroid terminologies
Android terminologies
 
Answer1)Responsive design is the idea where all the developed pag.pdf
Answer1)Responsive design is the idea where all the developed pag.pdfAnswer1)Responsive design is the idea where all the developed pag.pdf
Answer1)Responsive design is the idea where all the developed pag.pdf
 
Android Minnebar
Android MinnebarAndroid Minnebar
Android Minnebar
 

Dernier

Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 

Dernier (20)

Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 

Android Development project

  • 1. Android Development Made EasyW I t h S a m p l e P r o j e c t
  • 2. Outline:  Overview on Android  Installing ADT on Eclipse  Explore Project Components  Sample Project
  • 3. Android is an open mobile phone platform that was developed by Google and later by Open Handset Alliance. Google defines Android as a "software stack" for mobile phones. Software stack is made up of operating system(the platform on which everything runs), the middleware (the programming that allows applications to talk to a network and to one another) and the applications (the actual programs that phone will run)
  • 4. July 2005 - Google Inc. bought from Danger Inc Open Handset Alliance was formed headed by Google which is composed of companies like Intel, T- Mobile, Spring Nextel and more. In 2008, Android became available as an open source and ASOP(Android Open Source Project) is responsible for maintaining and development of android. February 2009, the first android version was released, Android 1.1. for Mobile G1.
  • 5.  Android 1.1  Android 1.5 Cupcake  Android 1.6 Donut  Android 2.0/2.1 Eclair  Android 2.2.x Froyo  Android 2.3.x Gingerbread  Android 3. x Honeycomb  Android 4.0.x Ice Cream Sandwich  Android 4.1 Jelly Bean
  • 6. Note: When developing an application, consider the market share of the android version. The higher the market share, the higher number your target market is.
  • 7. Note: Based on my development experience, ADT can run on at least Dual Core with at least 2GB RAM.
  • 9. Activity • Present a visual user interface for one focused endeavor the user can undertake • Example: a list of menu items users can choose from Services • Run in the background for an indefinite period of time • Example: calculate and provide the result to activities that need it Broadcast Receivers • Receive and react to broadcast announcements • Example: announcements that the time zone has changed Content Providers • Store and retrieve data and make it accessible to all applications • Example: Android ships with a number of content providers for common Intents • Hold the content of a message • Example: convey a request for an activity to present an image to the user or let the user edit some text
  • 10.
  • 11. public class CCSActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } }
  • 12.  Run in the background  Can continue even if Activity that started it dies  Should be used if something needs to be done while the user is not interacting with application  Otherwise, a thread is probably more applicable  Should create a new thread in the service to do work in, since the service runs in the main thread  Can be bound to an application  In which case will terminate when all applications bound to it unbind  Allows multiple applications to communicate with it via a common interface  Needs to be declared in manifest file  Like Activities, has a structured life cycle
  • 13.
  • 14. SRC • The project source code GEN • Auto generated code • Example: R.java Included libraries Resources • Drawables • Layout • Values like strings Manifest File • A must have xml file. Contains essential information about the system to the android system
  • 15.
  • 16.  Auto-generated: you shouldn’t edit it  Contains IDs of the project resources  Enforces good software engineering  Use findViewById and Resources object to get access to the resources  Ex. Button b = (Button)findViewById(R.id.button1)  Ex. getResources().getString(R.string.hello));
  • 17.
  • 18.
  • 19.  Eclipse has a great UI creator  Generates the XML for you  Composed of View objects  Can be specified for portrait and landscape mode  Use same file name, so can make completely different UIs for the orientations without modifying any code
  • 20.
  • 21.  Click ‘Create’ to make layout modifications  When in portrait mode can select ‘Portrait’ to make a res sub folder for portrait layouts  Likewise for Landscape layouts while in landscape mode  Will create folders titled ‘layout-port’ and ‘layout-land’  Note: these ‘port’ and ‘land’ folders are examples of ‘alternate layouts’, see here for more info  http://developer.android.com/guide/topics/resources/providing- resources.html  Avoid errors by making sure components have the same id in both orientations, and that you’ve tested each orientation thoroughly
  • 22.
  • 23. <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/ap k/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" android:id="@+id/tv_hello"/> <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Large Text“ android:textAppearance="?android:attr/textApp earanceLarge"/> </LinearLayout> res/values/string.xml
  • 24.
  • 25. 1. Lunching a new activity without expecting without expecting a result 2. Lunching a new activity and expecting a result when it finished. CalledActivity.class
  • 26.  On Eclipse IDE. Go To File > New > Project > Android Project  See image at the side for the prompt that appear. Click next button.
  • 27.  Select android version. Tip: select the latest OS version available. You can add minimum and target SDK on your manifest file to support earlier android versions.
  • 28.  Provide package name of your project. Valid package name consist of two names separated by a period.
  • 29.  Provide package name of your project. Valid package name consist of two names separated by a period.  Optional: Change minimum SDK for the lowest android version your application will support.  Hit on finish
  • 30.  Under res/layout on your project explorer. Open main.xml. Create a layout like this: In main.xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" > <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/button1" /> <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button 2" /> <Button android:id="@+id/button3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button 3" /> </LinearLayout> <EditText android:id="@+id/editText1" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" > <requestFocus /> </EditText> </LinearLayout>
  • 31.  Under res/values on your project explorer. Open strings.xml. <?xml version="1.0" encoding="utf-8"?> <resources> <string name="hello">Hello World, SampleProjectActivity!</string> <string name="app_name">SampleProject</string> <string name="button1">Button 1 Clicked.</string> </resources> NOTE: string with name button1 is being referenced by Button 1 android:text property. See main.xml in your layout.
  • 32.  Under SRC on your project explorer. Open SampleProjectActivity.java. Change code to this:  See comments for better understand. import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; public class SampleProjectActivity extends Activity implements OnClickListener{ /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Toast.makeText(this, "Hello.", Toast.LENGTH_LONG).show(); //referencing components in our layout as set in setContentView, - main.xml //findViewById is used hence we components in our layout will be called //through their ids as set in android:id properties. See main.xml in your layout. Button btn1 = (Button)findViewById(R.id.button1); //one way in handling click event btn1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //Toast is a prompt that will notify user of what has happened in the application //but not requiring user an action. Toast.makeText(getApplication(), "Button 1 Clicked", Toast.LENGTH_LONG).show(); } }); Button btn2 = (Button)findViewById(R.id.button2); Button btn3 = (Button)findViewById(R.id.button3); //Other way of handling event inside an activity btn2.setOnClickListener(this); btn3.setOnClickListener(this); } @Override public void onClick(View v) { // TODO Auto-generated method stub switch(v.getId()) { case R.id.button2: EditText editText = (EditText)findViewById(R.id.editText1); editText.setText("Button 2 Clicked!"); break; case R.id.button3: // Intent with out waiting for result. // This is creating a new view and passing the new controll to the next view. Intent intent = new Intent(this, NextActivity.class); startActivity(intent); break; } } }
  • 33.  Create NextActivity.java  Right click SRC folder > New > Class.  Change code to this: import android.app.Activity; import android.os.Bundle; import android.widget.Button; import android.widget.TextView; public class NextActivity extends Activity{ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // you can have a new layout. but for this example // we will be reusing the main.xml as our layout. // we will just manipulate the text to inform user that //a new activity has been created. setContentView(R.layout.main); // setTitle - change the title of the next view setTitle("Next Activity"); //setting page title TextView pageTitle = (TextView)findViewById(R.id.pagetitle); pageTitle.setText("Hello, You are now in the Next Activity Class."); Button btn1 = (Button)findViewById(R.id.button1); btn1.setText("Option 1"); Button btn2 = (Button)findViewById(R.id.button2); btn2.setText("Option 2"); Button btn3 = (Button)findViewById(R.id.button3); btn3.setText("Option 3"); } }
  • 34.  Open Manifest.xml in your project explorer.  Register NextActivity class to your project.  Your new manifest file must look like the code at the side.  Save all the changes <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/re s/android" package="com.sample" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15"/> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <activity android:name=".SampleBradActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHE R" /> </intent-filter> </activity> <activity android:name=".NextActivity" android:label="@string/app_name" /> </application> </manifest>
  • 35.  Right click your project name in your project explorer > RUN AS > ANDROID APPLICATION.  Emulator will boot up. Wait until home screen is shown.  Your application will be displayed on the screen.  You can now enjoy the application. Congratulations!!!
  • 36.  Installation: http://developershaven.net  Google API: http://mfarhan133.wordpress.com/2010/10/01/generate-google-maps-api-key-for-android/  Android Developer’s Website : http://developer.android.com/index.html  Numerous Forums & other developer sites, including:  http://www.javacodegeeks.com/2011/02/android-google-maps-tutorial.html  http://efreedom.com/Question/1-6070968/Google-Maps-Api-Directions  http://stackoverflow.com  http://www.anddev.org/google_driving_directions_-_mapview_overlayed-t826.html