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
PPT
Multiple Activity and Navigation Primer
PPT
Day 3: Getting Active Through Activities
PDF
Training android
PDF
Lecture 1 Session 1 Before Getting Started
PDF
AndroidManifest
PDF
Sensors in Android (old)
PPT
Day 4: Android: UI Widgets
Day: 2 Environment Setup for Android Application Development
Multiple Activity and Navigation Primer
Day 3: Getting Active Through Activities
Training android
Lecture 1 Session 1 Before Getting Started
AndroidManifest
Sensors in Android (old)
Day 4: Android: UI Widgets

What's hot (20)

PPTX
Android Workshop: Day 1 Part 3
PPTX
Day 15: Working in Background
PDF
Lecture 2(b) Android Internals A Quick Overview
PPTX
Introduction to Android Development: Before Getting Started
PDF
Ui layout (incomplete)
PDF
Day 1 Android: Before Getting Started
PPTX
Android MapView and MapActivity
PDF
Android Development: Build Android App from Scratch
PPTX
Android Development Training
PPT
Day 4: Android: Getting Active through Activities
PDF
Day1 before getting_started
PPT
Android development tutorial
PPTX
Android application-component
PPT
Google Android
PPTX
Android deep dive
PPT
Android Applications Development
PPT
android-tutorial-for-beginner
PPTX
Android app development
PPTX
Android before getting started
PPTX
Android Development for Beginners with Sample Project - Day 1
Android Workshop: Day 1 Part 3
Day 15: Working in Background
Lecture 2(b) Android Internals A Quick Overview
Introduction to Android Development: Before Getting Started
Ui layout (incomplete)
Day 1 Android: Before Getting Started
Android MapView and MapActivity
Android Development: Build Android App from Scratch
Android Development Training
Day 4: Android: Getting Active through Activities
Day1 before getting_started
Android development tutorial
Android application-component
Google Android
Android deep dive
Android Applications Development
android-tutorial-for-beginner
Android app development
Android before getting started
Android Development for Beginners with Sample Project - Day 1
Ad

Viewers also liked (14)

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

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

PPT
Android activity, service, and broadcast recievers
PPT
Android activity, service, and broadcast recievers
PDF
Android application development workshop day1
PDF
Android Development
PPT
Android | Busy Java Developers Guide to Android: UI | Ted Neward
PDF
Android activities & views
PPTX
Mobile Application Development-Components and Layouts
PPTX
Activity & Shared Preference
PDF
Introduction to Android Development
PPTX
Unit 5 Activity and Activity Life Cycle.pptx
PPTX
Lec-3-Mobile Application Development.pptx
PPTX
MDAD 4 - Android - Basics of UI Applications
PDF
Android application development
PDF
Android Bootcamp
PPTX
11.11.2020 - Unit 5-3 ACTIVITY, MENU AND SQLITE DATABASE.pptx
PDF
Introduction to Android Development with Java
DOCX
Android Application Components with Implementation & Examples
PPTX
Android session 2-behestee
PDF
Android application development workshop day1
PDF
Android Application Development - Level 1
Android activity, service, and broadcast recievers
Android activity, service, and broadcast recievers
Android application development workshop day1
Android Development
Android | Busy Java Developers Guide to Android: UI | Ted Neward
Android activities & views
Mobile Application Development-Components and Layouts
Activity & Shared Preference
Introduction to Android Development
Unit 5 Activity and Activity Life Cycle.pptx
Lec-3-Mobile Application Development.pptx
MDAD 4 - Android - Basics of UI Applications
Android application development
Android Bootcamp
11.11.2020 - Unit 5-3 ACTIVITY, MENU AND SQLITE DATABASE.pptx
Introduction to Android Development with Java
Android Application Components with Implementation & Examples
Android session 2-behestee
Android application development workshop day1
Android Application Development - Level 1

More from Ahsanul Karim (9)

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

Recently uploaded (20)

PPTX
A powerpoint presentation on the Revised K-10 Science Shaping Paper
PPTX
ELIAS-SEZIURE AND EPilepsy semmioan session.pptx
PDF
Indian roads congress 037 - 2012 Flexible pavement
DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PDF
Computing-Curriculum for Schools in Ghana
PDF
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 1)
PDF
IGGE1 Understanding the Self1234567891011
PDF
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf
PDF
Trump Administration's workforce development strategy
PDF
What if we spent less time fighting change, and more time building what’s rig...
PPTX
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
PDF
Τίμαιος είναι φιλοσοφικός διάλογος του Πλάτωνα
PDF
1.3 FINAL REVISED K-10 PE and Health CG 2023 Grades 4-10 (1).pdf
PDF
My India Quiz Book_20210205121199924.pdf
PDF
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
PPTX
B.Sc. DS Unit 2 Software Engineering.pptx
PDF
advance database management system book.pdf
PPTX
Virtual and Augmented Reality in Current Scenario
PDF
Paper A Mock Exam 9_ Attempt review.pdf.
PDF
FORM 1 BIOLOGY MIND MAPS and their schemes
A powerpoint presentation on the Revised K-10 Science Shaping Paper
ELIAS-SEZIURE AND EPilepsy semmioan session.pptx
Indian roads congress 037 - 2012 Flexible pavement
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
Computing-Curriculum for Schools in Ghana
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 1)
IGGE1 Understanding the Self1234567891011
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf
Trump Administration's workforce development strategy
What if we spent less time fighting change, and more time building what’s rig...
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
Τίμαιος είναι φιλοσοφικός διάλογος του Πλάτωνα
1.3 FINAL REVISED K-10 PE and Health CG 2023 Grades 4-10 (1).pdf
My India Quiz Book_20210205121199924.pdf
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
B.Sc. DS Unit 2 Software Engineering.pptx
advance database management system book.pdf
Virtual and Augmented Reality in Current Scenario
Paper A Mock Exam 9_ Attempt review.pdf.
FORM 1 BIOLOGY MIND MAPS and their schemes

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