SlideShare a Scribd company logo
Android Application Development Being Active Through Activities Ahsanul Karim [email_address] Sentinel Solutions Ltd. http://www.sentinelbd.com
Today We’re Covering… Application Structure Android Application Anatomy Activity Layout Using Layouts from Activity Activity Lifecycle Exercise
Project Structure… Created Project has the following structure Project Structure -Source ( src ) -Generated Class ( gen ) -Android 1.6 library -Assets ( assets ) -Resource( res ) - drawable-hdpi - drawable-ldpi - drawable-mdpi - layout - values - AndroidMenifest.xml - default.properties
Project Structure (Contd.) -Source ( src ) We have used only one class here which is an  Activity  named  HalloActivity.  We’ll describe about  Activity  in detail with lifecycle shortly. For now we can consider  Activity  as Android analogue for the window or dialog in a desktop application. It can load view from xml layout (here  main.xml  under  res/layout  folder) In the HelloActivity class the view of the Activity is set from main.xml given below
Project Structure (Contd.) -res/layout/main.xml UI Layout can be defined from source code using  View  or by layout xmls.  The layout xml can be generated by visual tool given by ADT
Project Structure (Contd.) -res/drawable From Android 1.6 to support different screen sizes and screen densities graphic files are kept in 3 different folders  drawable-hdpi ,  drawable-ldpi  and  drawable-mdpi In our current project, they contain only default icon file with different dimensions to support devices with different screen resolution. -assets Holds other static files you wish packaged with the application for deployment onto the device. In this project, we have none -gen/R.java -values/strings.xml
Project Structure (Contd.) -AndroidMenifest.xml XML file describing the application being built and what components – activities, services, etc. – are being supplied by that application
Let’s Build Something Useful… Objective:  To get hands-on experience of building something useful more than just “Hallo World”. Plan:  We’ll create a project to show how the basic building block Activity and some UI elements work. Output:  User will push a button and see current time. We’ll learn how to: Design UI from layout XML Set the layout in an Activity And make UI elements in action Steps: Creating project Design UI Add functionality to UI Run the application
Let’s Build Something Useful(Contd.) Creating the Project: Start Eclipse and go to  New > Project > Android Projec t
Let’s Build Something Useful(Contd.) Designing Layout (1) Edit layout/main.xml using the visual tool given by ADT by adding a  TextView  and a  Button  in a  LinearLayout  (more on layouts will be covered later)
Let’s Build Something Useful(Contd.) Designing Layout (2) The output xml is like below. We can directly edit layout xml to design the UI. Properties were set from the visual tool.
Let’s Build Something Useful(Contd.) Let’s infuse life to UI Activity with UI elements declared Initializing UI elements Auto-generated R.java Now: Adding Button action listener A method for getting time from Date class
Let’s Build Something Useful(Contd.) Complete Activity
Let’s Build Something Useful(Contd.) Complete Activity
Let’s Build Something Useful(Contd.) Creating Run Configuration and Run So, you can now create your own application
Android Activities Activity Activity provides a user generally with  an interactive screen  to do something like: Dialing the phone, View a map List of something for user to select or Anything you want your user to do An application usually consists of  multiple activities. Typically, one activity in an application is specified as the &quot; main &quot; activity, which is presented to the user when launching the application for the first time. (which is specified in  AndroidMenifest.xml )  The   <action>  element specifies that this is the &quot;main&quot; entry point to the application.  The  <category>  element specifies that this activity should be listed in the system's application  launcher (to allow users to launch this activity).
Android Activities (Contd..) Creating Activity We have already created Activities.  But how did we create it? Let’s revisit…  We created subclass of  Activity  base class We implemented one callback method  onCreate What is creating subclass??? What is callback methods??? Open Questions:
Android Activities (Contd..) Next Step: Implementing User Interface Design  res/layout/yourlayout.xml Use Views from Activity class Next Step: Implementing User Interface <manifest ... >   <application ... >       <activity android:name=&quot;.ExampleActivity&quot; />       ...   </application ... >   ... </manifest > Next Step: Starting Activity Intent intent = new Intent(this, ToActivity.class); startActivity(intent); We can start another activity by calling  startActivity() , passing it an  Intent  that describes the  activity you want to start.
Android Application Anatomy (Contd.) Application= Set of Android Components Activities Provides  User Interface Usually represents a  Single Screen Can contain one/more  Views Extends   the  Activity  Base class Services No   User Interface Runs in  Background Extends  the  Service  Base Class Content Provider Makes application  data available to other apps Data stored in  SQLite database Extends  the  ContentProvider   Base class Intent/Broadcast Receiver Receives and Reacts to broadcast  Intents No UI but  can start  an Activity Extends  the  BroadcastReceiver  Base Class
Activity Lifecycle

More Related Content

PPT
Day: 2 Environment Setup for Android Application Development
Ahsanul Karim
 
PPT
Multiple Activity and Navigation Primer
Ahsanul Karim
 
PPT
Day 3: Getting Active Through Activities
Ahsanul Karim
 
PDF
Training android
University of Technology
 
PDF
Lecture 1 Session 1 Before Getting Started
Ahsanul Karim
 
PDF
AndroidManifest
Ahsanul Karim
 
PDF
Sensors in Android (old)
Ahsanul Karim
 
PPT
Day 4: Android: UI Widgets
Ahsanul Karim
 
Day: 2 Environment Setup for Android Application Development
Ahsanul Karim
 
Multiple Activity and Navigation Primer
Ahsanul Karim
 
Day 3: Getting Active Through Activities
Ahsanul Karim
 
Training android
University of Technology
 
Lecture 1 Session 1 Before Getting Started
Ahsanul Karim
 
AndroidManifest
Ahsanul Karim
 
Sensors in Android (old)
Ahsanul Karim
 
Day 4: Android: UI Widgets
Ahsanul Karim
 

What's hot (20)

PPTX
Android Workshop: Day 1 Part 3
Ahsanul Karim
 
PPTX
Day 15: Working in Background
Ahsanul Karim
 
PDF
Lecture 2(b) Android Internals A Quick Overview
Ahsanul Karim
 
PPTX
Introduction to Android Development: Before Getting Started
Ahsanul Karim
 
PDF
Ui layout (incomplete)
Ahsanul Karim
 
PDF
Day 1 Android: Before Getting Started
Ahsanul Karim
 
PPTX
Android MapView and MapActivity
Ahsanul Karim
 
PDF
Android Development: Build Android App from Scratch
Taufan Erfiyanto
 
PPTX
Android Development Training
chandutata
 
PPT
Day 4: Android: Getting Active through Activities
Ahsanul Karim
 
PDF
Day1 before getting_started
Ahsanul Karim
 
PPT
Android development tutorial
nazzf
 
PPTX
Android application-component
Ly Haza
 
PPT
Google Android
Michael Angelo Rivera
 
PPTX
Android deep dive
AnuSahniNCI
 
PPT
Android Applications Development
Michael Angelo Rivera
 
PPT
android-tutorial-for-beginner
Ajailal Parackal
 
PPTX
Android app development
PiyushBhambhani1
 
PPTX
Android before getting started
Ahsanul Karim
 
PPTX
Android Development for Beginners with Sample Project - Day 1
Joemarie Amparo
 
Android Workshop: Day 1 Part 3
Ahsanul Karim
 
Day 15: Working in Background
Ahsanul Karim
 
Lecture 2(b) Android Internals A Quick Overview
Ahsanul Karim
 
Introduction to Android Development: Before Getting Started
Ahsanul Karim
 
Ui layout (incomplete)
Ahsanul Karim
 
Day 1 Android: Before Getting Started
Ahsanul Karim
 
Android MapView and MapActivity
Ahsanul Karim
 
Android Development: Build Android App from Scratch
Taufan Erfiyanto
 
Android Development Training
chandutata
 
Day 4: Android: Getting Active through Activities
Ahsanul Karim
 
Day1 before getting_started
Ahsanul Karim
 
Android development tutorial
nazzf
 
Android application-component
Ly Haza
 
Google Android
Michael Angelo Rivera
 
Android deep dive
AnuSahniNCI
 
Android Applications Development
Michael Angelo Rivera
 
android-tutorial-for-beginner
Ajailal Parackal
 
Android app development
PiyushBhambhani1
 
Android before getting started
Ahsanul Karim
 
Android Development for Beginners with Sample Project - Day 1
Joemarie Amparo
 
Ad

Viewers also liked (14)

PPTX
Creating the first app with android studio
Parinita03
 
PPT
Day 6: Android BroadcastReceiver Component
Ahsanul Karim
 
PPTX
Android GPS Tutorial
Ahsanul Karim
 
PPTX
Day: 1 Introduction to Mobile Application Development (in Android)
Ahsanul Karim
 
PPTX
Android Services
Ahsanul Karim
 
PPT
Android User Interface: Basic Form Widgets
Ahsanul Karim
 
PPTX
Day 9: Make Your App Location Aware using Location API
Ahsanul Karim
 
PPTX
Android User Interface Tutorial: DatePicker, TimePicker & Spinner
Ahsanul Karim
 
PPTX
Action Bar Sherlock tutorial
Ahsanul Karim
 
PDF
Lecture 3 getting active through activities
Ahsanul Karim
 
PDF
Day 8: Dealing with Lists and ListViews
Ahsanul Karim
 
PDF
List Views
Ahsanul Karim
 
PPTX
Android 1.8 sensor
Ahsanul Karim
 
PDF
Day 2 android internals a quick overview
Ahsanul Karim
 
Creating the first app with android studio
Parinita03
 
Day 6: Android BroadcastReceiver Component
Ahsanul Karim
 
Android GPS Tutorial
Ahsanul Karim
 
Day: 1 Introduction to Mobile Application Development (in Android)
Ahsanul Karim
 
Android Services
Ahsanul Karim
 
Android User Interface: Basic Form Widgets
Ahsanul Karim
 
Day 9: Make Your App Location Aware using Location API
Ahsanul Karim
 
Android User Interface Tutorial: DatePicker, TimePicker & Spinner
Ahsanul Karim
 
Action Bar Sherlock tutorial
Ahsanul Karim
 
Lecture 3 getting active through activities
Ahsanul Karim
 
Day 8: Dealing with Lists and ListViews
Ahsanul Karim
 
List Views
Ahsanul Karim
 
Android 1.8 sensor
Ahsanul Karim
 
Day 2 android internals a quick overview
Ahsanul Karim
 
Ad

Similar to Day 3: Getting Active Through Activities (20)

PPT
Android activity, service, and broadcast recievers
Jagdish Gediya
 
PPT
Android activity, service, and broadcast recievers
Utkarsh Mankad
 
PDF
Android application development workshop day1
Borhan Otour
 
PDF
Android Development
mclougm4
 
PPT
Android | Busy Java Developers Guide to Android: UI | Ted Neward
JAX London
 
PDF
Android activities & views
ma-polimi
 
PPTX
Mobile Application Development-Components and Layouts
Dr. Chandrakant Divate
 
PPTX
Activity & Shared Preference
nationalmobileapps
 
PDF
Introduction to Android Development
Aly Abdelkareem
 
PPTX
Unit 5 Activity and Activity Life Cycle.pptx
ShantanuDharekar
 
PPTX
Lec-3-Mobile Application Development.pptx
SheharBano86
 
PPTX
MDAD 4 - Android - Basics of UI Applications
Alexandru Radovici
 
PDF
Android application development
slidesuren
 
PDF
Android Bootcamp
ahkjsdcsadc
 
PPTX
11.11.2020 - Unit 5-3 ACTIVITY, MENU AND SQLITE DATABASE.pptx
MugiiiReee
 
PDF
Introduction to Android Development with Java
Jim McKeeth
 
DOCX
Android Application Components with Implementation & Examples
Dr. Chandrakant Divate
 
PPTX
Android session 2-behestee
Hussain Behestee
 
PDF
Android application development workshop day1
Borhan Otour
 
PDF
Android Application Development - Level 1
Isham Rashik
 
Android activity, service, and broadcast recievers
Jagdish Gediya
 
Android activity, service, and broadcast recievers
Utkarsh Mankad
 
Android application development workshop day1
Borhan Otour
 
Android Development
mclougm4
 
Android | Busy Java Developers Guide to Android: UI | Ted Neward
JAX London
 
Android activities & views
ma-polimi
 
Mobile Application Development-Components and Layouts
Dr. Chandrakant Divate
 
Activity & Shared Preference
nationalmobileapps
 
Introduction to Android Development
Aly Abdelkareem
 
Unit 5 Activity and Activity Life Cycle.pptx
ShantanuDharekar
 
Lec-3-Mobile Application Development.pptx
SheharBano86
 
MDAD 4 - Android - Basics of UI Applications
Alexandru Radovici
 
Android application development
slidesuren
 
Android Bootcamp
ahkjsdcsadc
 
11.11.2020 - Unit 5-3 ACTIVITY, MENU AND SQLITE DATABASE.pptx
MugiiiReee
 
Introduction to Android Development with Java
Jim McKeeth
 
Android Application Components with Implementation & Examples
Dr. Chandrakant Divate
 
Android session 2-behestee
Hussain Behestee
 
Android application development workshop day1
Borhan Otour
 
Android Application Development - Level 1
Isham Rashik
 

More from Ahsanul Karim (9)

PDF
Lecture 5: Storage: Saving Data Database, Files & Preferences
Ahsanul Karim
 
PDF
লেকচার ১ (ক)- শুরুর আগে:
Ahsanul Karim
 
PPTX
Day 15: Content Provider: Using Contacts API
Ahsanul Karim
 
PDF
Day 8: Dealing with Lists and ListViews
Ahsanul Karim
 
PPT
Day 5: Android User Interface [View Widgets]
Ahsanul Karim
 
DOC
Day 4: Activity lifecycle
Ahsanul Karim
 
PDF
Mobile Banking in Bangladesh: An Incomplete Study
Ahsanul Karim
 
PDF
GCM for Android
Ahsanul Karim
 
PPTX
Android Workshop Day 1 Part 2
Ahsanul Karim
 
Lecture 5: Storage: Saving Data Database, Files & Preferences
Ahsanul Karim
 
লেকচার ১ (ক)- শুরুর আগে:
Ahsanul Karim
 
Day 15: Content Provider: Using Contacts API
Ahsanul Karim
 
Day 8: Dealing with Lists and ListViews
Ahsanul Karim
 
Day 5: Android User Interface [View Widgets]
Ahsanul Karim
 
Day 4: Activity lifecycle
Ahsanul Karim
 
Mobile Banking in Bangladesh: An Incomplete Study
Ahsanul Karim
 
GCM for Android
Ahsanul Karim
 
Android Workshop Day 1 Part 2
Ahsanul Karim
 

Recently uploaded (20)

PPTX
Cleaning Validation Ppt Pharmaceutical validation
Ms. Ashatai Patil
 
PPTX
How to Apply for a Job From Odoo 18 Website
Celine George
 
PDF
Biological Classification Class 11th NCERT CBSE NEET.pdf
NehaRohtagi1
 
PPTX
Applications of matrices In Real Life_20250724_091307_0000.pptx
gehlotkrish03
 
PDF
Review of Related Literature & Studies.pdf
Thelma Villaflores
 
PPTX
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
PPTX
Command Palatte in Odoo 18.1 Spreadsheet - Odoo Slides
Celine George
 
PPTX
Continental Accounting in Odoo 18 - Odoo Slides
Celine George
 
PPTX
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
PPTX
HEALTH CARE DELIVERY SYSTEM - UNIT 2 - GNM 3RD YEAR.pptx
Priyanshu Anand
 
PDF
The-Invisible-Living-World-Beyond-Our-Naked-Eye chapter 2.pdf/8th science cur...
Sandeep Swamy
 
PPTX
An introduction to Dialogue writing.pptx
drsiddhantnagine
 
PPTX
Gupta Art & Architecture Temple and Sculptures.pptx
Virag Sontakke
 
PPTX
PROTIEN ENERGY MALNUTRITION: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
 
PDF
Virat Kohli- the Pride of Indian cricket
kushpar147
 
PPTX
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
PPTX
20250924 Navigating the Future: How to tell the difference between an emergen...
McGuinness Institute
 
DOCX
Modul Ajar Deep Learning Bahasa Inggris Kelas 11 Terbaru 2025
wahyurestu63
 
PPTX
INTESTINALPARASITES OR WORM INFESTATIONS.pptx
PRADEEP ABOTHU
 
PPTX
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
Cleaning Validation Ppt Pharmaceutical validation
Ms. Ashatai Patil
 
How to Apply for a Job From Odoo 18 Website
Celine George
 
Biological Classification Class 11th NCERT CBSE NEET.pdf
NehaRohtagi1
 
Applications of matrices In Real Life_20250724_091307_0000.pptx
gehlotkrish03
 
Review of Related Literature & Studies.pdf
Thelma Villaflores
 
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
Command Palatte in Odoo 18.1 Spreadsheet - Odoo Slides
Celine George
 
Continental Accounting in Odoo 18 - Odoo Slides
Celine George
 
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
HEALTH CARE DELIVERY SYSTEM - UNIT 2 - GNM 3RD YEAR.pptx
Priyanshu Anand
 
The-Invisible-Living-World-Beyond-Our-Naked-Eye chapter 2.pdf/8th science cur...
Sandeep Swamy
 
An introduction to Dialogue writing.pptx
drsiddhantnagine
 
Gupta Art & Architecture Temple and Sculptures.pptx
Virag Sontakke
 
PROTIEN ENERGY MALNUTRITION: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
 
Virat Kohli- the Pride of Indian cricket
kushpar147
 
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
20250924 Navigating the Future: How to tell the difference between an emergen...
McGuinness Institute
 
Modul Ajar Deep Learning Bahasa Inggris Kelas 11 Terbaru 2025
wahyurestu63
 
INTESTINALPARASITES OR WORM INFESTATIONS.pptx
PRADEEP ABOTHU
 
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 

Day 3: Getting Active Through Activities

  • 1. Android Application Development Being Active Through Activities Ahsanul Karim [email_address] Sentinel Solutions Ltd. http://www.sentinelbd.com
  • 2. Today We’re Covering… Application Structure Android Application Anatomy Activity Layout Using Layouts from Activity Activity Lifecycle Exercise
  • 3. Project Structure… Created Project has the following structure Project Structure -Source ( src ) -Generated Class ( gen ) -Android 1.6 library -Assets ( assets ) -Resource( res ) - drawable-hdpi - drawable-ldpi - drawable-mdpi - layout - values - AndroidMenifest.xml - default.properties
  • 4. Project Structure (Contd.) -Source ( src ) We have used only one class here which is an Activity named HalloActivity. We’ll describe about Activity in detail with lifecycle shortly. For now we can consider Activity as Android analogue for the window or dialog in a desktop application. It can load view from xml layout (here main.xml under res/layout folder) In the HelloActivity class the view of the Activity is set from main.xml given below
  • 5. Project Structure (Contd.) -res/layout/main.xml UI Layout can be defined from source code using View or by layout xmls. The layout xml can be generated by visual tool given by ADT
  • 6. Project Structure (Contd.) -res/drawable From Android 1.6 to support different screen sizes and screen densities graphic files are kept in 3 different folders drawable-hdpi , drawable-ldpi and drawable-mdpi In our current project, they contain only default icon file with different dimensions to support devices with different screen resolution. -assets Holds other static files you wish packaged with the application for deployment onto the device. In this project, we have none -gen/R.java -values/strings.xml
  • 7. Project Structure (Contd.) -AndroidMenifest.xml XML file describing the application being built and what components – activities, services, etc. – are being supplied by that application
  • 8. Let’s Build Something Useful… Objective: To get hands-on experience of building something useful more than just “Hallo World”. Plan: We’ll create a project to show how the basic building block Activity and some UI elements work. Output: User will push a button and see current time. We’ll learn how to: Design UI from layout XML Set the layout in an Activity And make UI elements in action Steps: Creating project Design UI Add functionality to UI Run the application
  • 9. Let’s Build Something Useful(Contd.) Creating the Project: Start Eclipse and go to New > Project > Android Projec t
  • 10. Let’s Build Something Useful(Contd.) Designing Layout (1) Edit layout/main.xml using the visual tool given by ADT by adding a TextView and a Button in a LinearLayout (more on layouts will be covered later)
  • 11. Let’s Build Something Useful(Contd.) Designing Layout (2) The output xml is like below. We can directly edit layout xml to design the UI. Properties were set from the visual tool.
  • 12. Let’s Build Something Useful(Contd.) Let’s infuse life to UI Activity with UI elements declared Initializing UI elements Auto-generated R.java Now: Adding Button action listener A method for getting time from Date class
  • 13. Let’s Build Something Useful(Contd.) Complete Activity
  • 14. Let’s Build Something Useful(Contd.) Complete Activity
  • 15. Let’s Build Something Useful(Contd.) Creating Run Configuration and Run So, you can now create your own application
  • 16. Android Activities Activity Activity provides a user generally with an interactive screen to do something like: Dialing the phone, View a map List of something for user to select or Anything you want your user to do An application usually consists of multiple activities. Typically, one activity in an application is specified as the &quot; main &quot; activity, which is presented to the user when launching the application for the first time. (which is specified in AndroidMenifest.xml )  The   <action>  element specifies that this is the &quot;main&quot; entry point to the application. The  <category>  element specifies that this activity should be listed in the system's application launcher (to allow users to launch this activity).
  • 17. Android Activities (Contd..) Creating Activity We have already created Activities. But how did we create it? Let’s revisit… We created subclass of Activity base class We implemented one callback method onCreate What is creating subclass??? What is callback methods??? Open Questions:
  • 18. Android Activities (Contd..) Next Step: Implementing User Interface Design res/layout/yourlayout.xml Use Views from Activity class Next Step: Implementing User Interface <manifest ... >   <application ... >       <activity android:name=&quot;.ExampleActivity&quot; />       ...   </application ... >   ... </manifest > Next Step: Starting Activity Intent intent = new Intent(this, ToActivity.class); startActivity(intent); We can start another activity by calling  startActivity() , passing it an  Intent  that describes the activity you want to start.
  • 19. Android Application Anatomy (Contd.) Application= Set of Android Components Activities Provides User Interface Usually represents a Single Screen Can contain one/more Views Extends the Activity Base class Services No User Interface Runs in Background Extends the Service Base Class Content Provider Makes application data available to other apps Data stored in SQLite database Extends the ContentProvider Base class Intent/Broadcast Receiver Receives and Reacts to broadcast Intents No UI but can start an Activity Extends the BroadcastReceiver Base Class