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
Multiple Activity and Navigation Primer
Ahsanul Karim
 
PPT
Day: 2 Environment Setup for Android Application Development
Ahsanul Karim
 
PPTX
Android MapView and MapActivity
Ahsanul Karim
 
PPT
Day 4: Android: UI Widgets
Ahsanul Karim
 
PDF
Training android
University of Technology
 
PPTX
Android UI
nationalmobileapps
 
PPTX
Android Workshop: Day 1 Part 3
Ahsanul Karim
 
PPTX
Day 15: Working in Background
Ahsanul Karim
 
Multiple Activity and Navigation Primer
Ahsanul Karim
 
Day: 2 Environment Setup for Android Application Development
Ahsanul Karim
 
Android MapView and MapActivity
Ahsanul Karim
 
Day 4: Android: UI Widgets
Ahsanul Karim
 
Training android
University of Technology
 
Android UI
nationalmobileapps
 
Android Workshop: Day 1 Part 3
Ahsanul Karim
 
Day 15: Working in Background
Ahsanul Karim
 

What's hot (20)

PDF
Sensors in Android (old)
Ahsanul Karim
 
PPT
android layouts
Deepa Rani
 
PDF
AndroidManifest
Ahsanul Karim
 
PPT
Londroid Android Home Screen Widgets
Richard Hyndman
 
PDF
Ui layout (incomplete)
Ahsanul Karim
 
PPTX
Android Application Component: BroadcastReceiver Tutorial
Ahsanul Karim
 
PPT
Day 4: Android: Getting Active through Activities
Ahsanul Karim
 
PDF
Marakana Android User Interface
Marko Gargenta
 
PPTX
Android User Interface
Shakib Hasan Sumon
 
PDF
Create yourfirstandroidapppdf
murad3003
 
PDF
Ios actions and outlets
veeracynixit
 
PPTX
Android Services
Ahsanul Karim
 
PPTX
Create New Android Activity
Transpose Solutions Inc
 
PPT
Android Bootcamp Tanzania:understanding ui in_android
Denis Minja
 
PPTX
Create New Android Layout
Transpose Solutions Inc
 
PDF
Android session 2
Ahesanali Suthar
 
PDF
Android session 1
Ahesanali Suthar
 
PPTX
Android application-component
Ly Haza
 
PDF
Android session 3
Ahesanali Suthar
 
PDF
Android ui layout
Krazy Koder
 
Sensors in Android (old)
Ahsanul Karim
 
android layouts
Deepa Rani
 
AndroidManifest
Ahsanul Karim
 
Londroid Android Home Screen Widgets
Richard Hyndman
 
Ui layout (incomplete)
Ahsanul Karim
 
Android Application Component: BroadcastReceiver Tutorial
Ahsanul Karim
 
Day 4: Android: Getting Active through Activities
Ahsanul Karim
 
Marakana Android User Interface
Marko Gargenta
 
Android User Interface
Shakib Hasan Sumon
 
Create yourfirstandroidapppdf
murad3003
 
Ios actions and outlets
veeracynixit
 
Android Services
Ahsanul Karim
 
Create New Android Activity
Transpose Solutions Inc
 
Android Bootcamp Tanzania:understanding ui in_android
Denis Minja
 
Create New Android Layout
Transpose Solutions Inc
 
Android session 2
Ahesanali Suthar
 
Android session 1
Ahesanali Suthar
 
Android application-component
Ly Haza
 
Android session 3
Ahesanali Suthar
 
Android ui layout
Krazy Koder
 
Ad

Viewers also liked (12)

PDF
Android App development and test environment, Understaing android app structure
Vijay Rastogi
 
PPTX
Android Workshop Day 1 Part 2
Ahsanul Karim
 
PPTX
Android Tutorials : Basic widgets
Prajyot Mainkar
 
PPSX
Screen orientations in android
manjakannar
 
PPT
Android application structure
Alexey Ustenko
 
PPT
Day 3: Getting Active Through Activities
Ahsanul Karim
 
PPTX
Introduction to android
zeelpatel0504
 
PPTX
Day 9: Make Your App Location Aware using Location API
Ahsanul Karim
 
PPTX
Android User Interface Tutorial: DatePicker, TimePicker & Spinner
Ahsanul Karim
 
PPTX
Android GPS Tutorial
Ahsanul Karim
 
PPT
Android User Interface: Basic Form Widgets
Ahsanul Karim
 
Android App development and test environment, Understaing android app structure
Vijay Rastogi
 
Android Workshop Day 1 Part 2
Ahsanul Karim
 
Android Tutorials : Basic widgets
Prajyot Mainkar
 
Screen orientations in android
manjakannar
 
Android application structure
Alexey Ustenko
 
Day 3: Getting Active Through Activities
Ahsanul Karim
 
Introduction to android
zeelpatel0504
 
Day 9: Make Your App Location Aware using Location API
Ahsanul Karim
 
Android User Interface Tutorial: DatePicker, TimePicker & Spinner
Ahsanul Karim
 
Android GPS Tutorial
Ahsanul Karim
 
Android User Interface: Basic Form Widgets
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 (20)

PDF
Lecture 5: Storage: Saving Data Database, Files & Preferences
Ahsanul Karim
 
PDF
Lecture 3 getting active through activities
Ahsanul Karim
 
PDF
Lecture 2(b) Android Internals A Quick Overview
Ahsanul Karim
 
PDF
Lecture 1 Session 1 Before Getting Started
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
 
PDF
Day 8: Dealing with Lists and ListViews
Ahsanul Karim
 
PPT
Day 6: Android BroadcastReceiver Component
Ahsanul Karim
 
PPT
Day 5: Android User Interface [View Widgets]
Ahsanul Karim
 
DOC
Day 4: Activity lifecycle
Ahsanul Karim
 
PDF
Day 2 android internals a quick overview
Ahsanul Karim
 
PDF
Day 1 Android: Before Getting Started
Ahsanul Karim
 
PDF
Mobile Banking in Bangladesh: An Incomplete Study
Ahsanul Karim
 
PDF
GCM for Android
Ahsanul Karim
 
PDF
List Views
Ahsanul Karim
 
PDF
Day1 before getting_started
Ahsanul Karim
 
PPTX
Action Bar Sherlock tutorial
Ahsanul Karim
 
PPTX
Android 1.8 sensor
Ahsanul Karim
 
PPTX
Android before getting started
Ahsanul Karim
 
Lecture 5: Storage: Saving Data Database, Files & Preferences
Ahsanul Karim
 
Lecture 3 getting active through activities
Ahsanul Karim
 
Lecture 2(b) Android Internals A Quick Overview
Ahsanul Karim
 
Lecture 1 Session 1 Before Getting Started
Ahsanul Karim
 
লেকচার ১ (ক)- শুরুর আগে:
Ahsanul Karim
 
Day 15: Content Provider: Using Contacts API
Ahsanul Karim
 
Day 8: Dealing with Lists and ListViews
Ahsanul Karim
 
Day 8: Dealing with Lists and ListViews
Ahsanul Karim
 
Day 6: Android BroadcastReceiver Component
Ahsanul Karim
 
Day 5: Android User Interface [View Widgets]
Ahsanul Karim
 
Day 4: Activity lifecycle
Ahsanul Karim
 
Day 2 android internals a quick overview
Ahsanul Karim
 
Day 1 Android: Before Getting Started
Ahsanul Karim
 
Mobile Banking in Bangladesh: An Incomplete Study
Ahsanul Karim
 
GCM for Android
Ahsanul Karim
 
List Views
Ahsanul Karim
 
Day1 before getting_started
Ahsanul Karim
 
Action Bar Sherlock tutorial
Ahsanul Karim
 
Android 1.8 sensor
Ahsanul Karim
 
Android before getting started
Ahsanul Karim
 

Recently uploaded (20)

PDF
2.Reshaping-Indias-Political-Map.ppt/pdf/8th class social science Exploring S...
Sandeep Swamy
 
PPTX
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
PDF
The-Invisible-Living-World-Beyond-Our-Naked-Eye chapter 2.pdf/8th science cur...
Sandeep Swamy
 
PPTX
Care of patients with elImination deviation.pptx
AneetaSharma15
 
PPTX
INTESTINALPARASITES OR WORM INFESTATIONS.pptx
PRADEEP ABOTHU
 
PDF
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
PPTX
An introduction to Dialogue writing.pptx
drsiddhantnagine
 
PDF
RA 12028_ARAL_Orientation_Day-2-Sessions_v2.pdf
Seven De Los Reyes
 
PPTX
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
PDF
Biological Classification Class 11th NCERT CBSE NEET.pdf
NehaRohtagi1
 
PDF
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
DOCX
Unit 5: Speech-language and swallowing disorders
JELLA VISHNU DURGA PRASAD
 
DOCX
Action Plan_ARAL PROGRAM_ STAND ALONE SHS.docx
Levenmartlacuna1
 
PPTX
BASICS IN COMPUTER APPLICATIONS - UNIT I
suganthim28
 
PPTX
CONCEPT OF CHILD CARE. pptx
AneetaSharma15
 
PDF
Module 2: Public Health History [Tutorial Slides]
JonathanHallett4
 
PPTX
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
DOCX
Modul Ajar Deep Learning Bahasa Inggris Kelas 11 Terbaru 2025
wahyurestu63
 
PPTX
HEALTH CARE DELIVERY SYSTEM - UNIT 2 - GNM 3RD YEAR.pptx
Priyanshu Anand
 
PPTX
How to Apply for a Job From Odoo 18 Website
Celine George
 
2.Reshaping-Indias-Political-Map.ppt/pdf/8th class social science Exploring S...
Sandeep Swamy
 
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
The-Invisible-Living-World-Beyond-Our-Naked-Eye chapter 2.pdf/8th science cur...
Sandeep Swamy
 
Care of patients with elImination deviation.pptx
AneetaSharma15
 
INTESTINALPARASITES OR WORM INFESTATIONS.pptx
PRADEEP ABOTHU
 
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
An introduction to Dialogue writing.pptx
drsiddhantnagine
 
RA 12028_ARAL_Orientation_Day-2-Sessions_v2.pdf
Seven De Los Reyes
 
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
Biological Classification Class 11th NCERT CBSE NEET.pdf
NehaRohtagi1
 
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
Unit 5: Speech-language and swallowing disorders
JELLA VISHNU DURGA PRASAD
 
Action Plan_ARAL PROGRAM_ STAND ALONE SHS.docx
Levenmartlacuna1
 
BASICS IN COMPUTER APPLICATIONS - UNIT I
suganthim28
 
CONCEPT OF CHILD CARE. pptx
AneetaSharma15
 
Module 2: Public Health History [Tutorial Slides]
JonathanHallett4
 
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
Modul Ajar Deep Learning Bahasa Inggris Kelas 11 Terbaru 2025
wahyurestu63
 
HEALTH CARE DELIVERY SYSTEM - UNIT 2 - GNM 3RD YEAR.pptx
Priyanshu Anand
 
How to Apply for a Job From Odoo 18 Website
Celine George
 

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