SlideShare a Scribd company logo
Mobile Application
Development
Instructor:
Muhammad Jameel
Muhammad.jameel@superior.edu.pk
Outline
Android UI concepts, What is screen size, what is screen density, what is screen orientation,
screen resolution, UI measurement units, density independent pixels, scale independent
pixels
The Android User Interface Concept
What is screen size?
• Physical size which is measured along side the diagonal is called screen
size.
• There are four general sizes small, normal, large and extra large.
What is screen density?
• Number of pixels in an inch known as dpi (dots per inch) or ppi (pixel per
inch). Every Android device has a different density, they just fall broadly
into these four categories.
There are four main categories.
1. ldpi,
2. mdpi
3. hdpi
4. xhdpi
• If you are using pixel as the base unit then the problem is density will be
different on the different devices.
What happens if you give the actual pixels, and what happens when you give
measurements in dpi?
• All resources by default are considered for mdpi and scaled by the Android
for other configurations.
Why screen densities matter the most in Android?
• Because you specify the measurements in dp, so Android multiply these
with these values for the appropriate device, so you don’t have to worry
about how big its going to look on different screens with different densities.
What is screen orientation?
• Aspect ratio = width / height
• Aspect ratio is tall: portrait
• Aspect ratio is wide: landscape
What is screen resolution?
• Number of pixels on the screen is called screen resolution.
• In android you should not be concerned with screen resolution, you don’t
work with the screen resolution, because it various so much.
• There are many device out there and each device has a different screen
resolution.
• Work only with the screen sizes and screen densities for cross device
support.
Android User Interface Measurement Units
What is density independent pixels?
• It is a virtual pixel to define dimensions and position.
• You want to say 100dp and don’t want to worry about how big it looks on
different screen sizes, you want android to take care how big or
appropriate it should look across different devices.
• So system converts the dps to pixels when your application runs.
• It calculates the pixels out of your specified dps by multiplying that with
dot per inch on your device and dividing that by 160.
• Android automatically applies the scaling factor for different devices.
• Density independent means preserve the physical size of the UI across
different devices with different screen densities.
What do you get with density independent
pixels?
• What happens without density independent pixels and what happens with
density independent pixels?
What are scaled pixels?
• It is the same concept as the density independent pixels, but it is only for
fonts.
• It is virtual pixels scaled according to density and user font preferences.
Toast
• Toast is nothing more than a message than appears on the screen or
activity of your application.
• It appears for short durations and then it disappears.
Why we use Toast
• Giving user feedback regarding some operation.
• It doesn’t block the activity or the fragment in which it appears.
• It is not like dialog it just appear on the top of your activity and disappears
after a short time.
Example
How to create Toast Object?
• We use static method makeToast() with three parameters.
• Context, which is simple way to get resources in Android and to
access the system level services for example services like GPS,
alarm services, notification services and so on.
• So context are the way to those services and you need to pass
the context object inside the makeToast() method.
• The next is the CharSequence which is simply the text that you
want to display.
• And at the last is the duration, which can only take two values.
• Both are the static fields inside the Toast class.
• And after this most important part is to call the show() method
with the help of Toast object.
• You can display toast even from a service.
Example
Example
Controlling Toast’s Position on the screen
X and Y distance is relative to Gravity attribute
• Remember x and y distance is relative to gravity attribute. If you
set gravity to left then it will calculate x and y distance from left.
• Similarly if you have set the gravity to center then it will
calculate x and y distance from center.
• Create a custom layout file.
• Make changes in activity_main.xml file.
What is an Activity?
• All those things which present something to you with which you can
interact are called activities in android application development.
• Activities are nothing but screens.
Activity Life Cycle
What activities do?
• They draws its user interface (UI) on the screen.
• Your application can have many activities but there is only one main
activity, just like in C++ there is only one main function, same way your
application have only one main activity.
• Main activity takes care of launching your application.
• An activity can start any other activity belonging to itself.
• When a new activity starts, the previous activity stopped and added to a
stack known as back-stack.
How do I know when Activity is visible to
user/paused/stopped?
• There are only two things that can happen either user is using your
application or user is not using your application.
• There should be some kind of way of know whether using is using your
activity or not.
• This can be achieved by using the special methods called Lifecycle
Methods.
• These methods tell whether your activity is being used by the user or not,
whether your activity is paused or stopped, these methods tell about the
current situation of your activity.
Why do I need these methods? What do I do with these
methods?
• These methods simply defines how application behaves.
What is call back method?
• Android OS calls certain methods on your activity to notify whether your
application is running or not.
Activity Lifecycle
• What happens when user clicks on the application icon?
Three methods call.
1. onCreate()
2. onStart()
3. onResume()
• What happens when user actually tries to pause your application?
1. onPause()
2. onStop()
• What happens when you go back to your application?
1. onRestart()
2. onStart()
3. onResume()
• onDestroy() is called when you manually stop your application to free the memory.
• When you’ve dialog box which partially blocks your screen, only onPause()
is called.
• When you’ve something which blocks your whole screen, at that time
onPause() and onStop() is called.
• When your activity is called.
• This is where when your user is attracting with your application. All the
attraction comes under this place.
• If you go back to your application.
• What if you change the orientation of the screen?
Example
General Guidelines
• Don’t do the heavy processing or network consuming operations when user
is currently away from your application.
• Application should not crash when another application is started.
• Don’t lose the user’s progress or session data.
Assignment_03
Create a Toast message by showing any text message on the screen and
create Toast to show the message on the different position on screen
also show with any image.

More Related Content

Similar to W2_Lec03_Lec_04_Activity.pptx

Android Application Development
Android Application DevelopmentAndroid Application Development
Android Application Development
Azfar Siddiqui
 
1 PROGRAM ISEM RESEARCH PAPER FOR APPLIED.docx
1 PROGRAM ISEM RESEARCH PAPER FOR APPLIED.docx1 PROGRAM ISEM RESEARCH PAPER FOR APPLIED.docx
1 PROGRAM ISEM RESEARCH PAPER FOR APPLIED.docx
honey725342
 
B2. activity and intent
B2. activity and intentB2. activity and intent
B2. activity and intent
PERKYTORIALS
 
Android bootcamp-day1
Android bootcamp-day1Android bootcamp-day1
Android bootcamp-day1
FatimaYousif11
 
Android Development Tutorial
Android Development TutorialAndroid Development Tutorial
Android Development Tutorial
Germán Bringas
 
Notes Unit3.pptx
Notes Unit3.pptxNotes Unit3.pptx
Notes Unit3.pptx
MIT Autonomous Aurangabad
 
Define & design apps for success en
Define & design apps for success enDefine & design apps for success en
Define & design apps for success enAcrmnet s.r.l.
 
Practical UI Guidelines for Wearable Apps
Practical UI Guidelines for Wearable AppsPractical UI Guidelines for Wearable Apps
Practical UI Guidelines for Wearable Apps
Victor Dibia
 
Android app development
Android app developmentAndroid app development
Android app development
PiyushBhambhani1
 
hema ppt (2).pptx
hema ppt (2).pptxhema ppt (2).pptx
hema ppt (2).pptx
balasekaran5
 
C maksymchuk android
C maksymchuk androidC maksymchuk android
C maksymchuk android
sdeconf
 
W5_Lec09_Lec10_Intents.pptx
W5_Lec09_Lec10_Intents.pptxW5_Lec09_Lec10_Intents.pptx
W5_Lec09_Lec10_Intents.pptx
ChSalmanSalman
 
Dori waldman android _course_2
Dori waldman android _course_2Dori waldman android _course_2
Dori waldman android _course_2
Dori Waldman
 
Nearsoft Mobile Onboarding Workshop
Nearsoft Mobile Onboarding WorkshopNearsoft Mobile Onboarding Workshop
Nearsoft Mobile Onboarding Workshop
Misael Leon
 
task manager presentation in Operating System
task manager presentation in Operating System task manager presentation in Operating System
task manager presentation in Operating System
FariaChaudhry6
 
Productivity Apps and Tools for Workplace version (0.8.2)
Productivity Apps and Tools for Workplace version (0.8.2)Productivity Apps and Tools for Workplace version (0.8.2)
Productivity Apps and Tools for Workplace version (0.8.2)
DreamKonnect Consulting
 
UI Design
UI DesignUI Design
UI Design
Ivano Malavolta
 
Android Programming Basic
Android Programming BasicAndroid Programming Basic
Android Programming BasicDuy Do Phan
 
Android_Workshop
Android_WorkshopAndroid_Workshop
Android_WorkshopSenthil ACS
 
Ux design-fundamentals
Ux design-fundamentalsUx design-fundamentals
Ux design-fundamentals
Muhammad Ishfaq Ch ✔
 

Similar to W2_Lec03_Lec_04_Activity.pptx (20)

Android Application Development
Android Application DevelopmentAndroid Application Development
Android Application Development
 
1 PROGRAM ISEM RESEARCH PAPER FOR APPLIED.docx
1 PROGRAM ISEM RESEARCH PAPER FOR APPLIED.docx1 PROGRAM ISEM RESEARCH PAPER FOR APPLIED.docx
1 PROGRAM ISEM RESEARCH PAPER FOR APPLIED.docx
 
B2. activity and intent
B2. activity and intentB2. activity and intent
B2. activity and intent
 
Android bootcamp-day1
Android bootcamp-day1Android bootcamp-day1
Android bootcamp-day1
 
Android Development Tutorial
Android Development TutorialAndroid Development Tutorial
Android Development Tutorial
 
Notes Unit3.pptx
Notes Unit3.pptxNotes Unit3.pptx
Notes Unit3.pptx
 
Define & design apps for success en
Define & design apps for success enDefine & design apps for success en
Define & design apps for success en
 
Practical UI Guidelines for Wearable Apps
Practical UI Guidelines for Wearable AppsPractical UI Guidelines for Wearable Apps
Practical UI Guidelines for Wearable Apps
 
Android app development
Android app developmentAndroid app development
Android app development
 
hema ppt (2).pptx
hema ppt (2).pptxhema ppt (2).pptx
hema ppt (2).pptx
 
C maksymchuk android
C maksymchuk androidC maksymchuk android
C maksymchuk android
 
W5_Lec09_Lec10_Intents.pptx
W5_Lec09_Lec10_Intents.pptxW5_Lec09_Lec10_Intents.pptx
W5_Lec09_Lec10_Intents.pptx
 
Dori waldman android _course_2
Dori waldman android _course_2Dori waldman android _course_2
Dori waldman android _course_2
 
Nearsoft Mobile Onboarding Workshop
Nearsoft Mobile Onboarding WorkshopNearsoft Mobile Onboarding Workshop
Nearsoft Mobile Onboarding Workshop
 
task manager presentation in Operating System
task manager presentation in Operating System task manager presentation in Operating System
task manager presentation in Operating System
 
Productivity Apps and Tools for Workplace version (0.8.2)
Productivity Apps and Tools for Workplace version (0.8.2)Productivity Apps and Tools for Workplace version (0.8.2)
Productivity Apps and Tools for Workplace version (0.8.2)
 
UI Design
UI DesignUI Design
UI Design
 
Android Programming Basic
Android Programming BasicAndroid Programming Basic
Android Programming Basic
 
Android_Workshop
Android_WorkshopAndroid_Workshop
Android_Workshop
 
Ux design-fundamentals
Ux design-fundamentalsUx design-fundamentals
Ux design-fundamentals
 

More from ssuserc1e786

LEC 1.pptx
LEC 1.pptxLEC 1.pptx
LEC 1.pptx
ssuserc1e786
 
Bcsm-f20-405(Web-design).pptx
Bcsm-f20-405(Web-design).pptxBcsm-f20-405(Web-design).pptx
Bcsm-f20-405(Web-design).pptx
ssuserc1e786
 
W1_Lec01_Lec02_Layouts.pptx
W1_Lec01_Lec02_Layouts.pptxW1_Lec01_Lec02_Layouts.pptx
W1_Lec01_Lec02_Layouts.pptx
ssuserc1e786
 
Lecture W5 CN IP Subnetting P2.pptx
Lecture W5 CN IP Subnetting P2.pptxLecture W5 CN IP Subnetting P2.pptx
Lecture W5 CN IP Subnetting P2.pptx
ssuserc1e786
 
Lecture W2 CN Network Types, Layered approach.pptx
Lecture W2 CN Network Types, Layered approach.pptxLecture W2 CN Network Types, Layered approach.pptx
Lecture W2 CN Network Types, Layered approach.pptx
ssuserc1e786
 
Lecture W4 CN IP Addressing P1.pptx
Lecture W4 CN IP Addressing P1.pptxLecture W4 CN IP Addressing P1.pptx
Lecture W4 CN IP Addressing P1.pptx
ssuserc1e786
 
W1_Lec01_Lec02_Intro.pptx
W1_Lec01_Lec02_Intro.pptxW1_Lec01_Lec02_Intro.pptx
W1_Lec01_Lec02_Intro.pptx
ssuserc1e786
 

More from ssuserc1e786 (7)

LEC 1.pptx
LEC 1.pptxLEC 1.pptx
LEC 1.pptx
 
Bcsm-f20-405(Web-design).pptx
Bcsm-f20-405(Web-design).pptxBcsm-f20-405(Web-design).pptx
Bcsm-f20-405(Web-design).pptx
 
W1_Lec01_Lec02_Layouts.pptx
W1_Lec01_Lec02_Layouts.pptxW1_Lec01_Lec02_Layouts.pptx
W1_Lec01_Lec02_Layouts.pptx
 
Lecture W5 CN IP Subnetting P2.pptx
Lecture W5 CN IP Subnetting P2.pptxLecture W5 CN IP Subnetting P2.pptx
Lecture W5 CN IP Subnetting P2.pptx
 
Lecture W2 CN Network Types, Layered approach.pptx
Lecture W2 CN Network Types, Layered approach.pptxLecture W2 CN Network Types, Layered approach.pptx
Lecture W2 CN Network Types, Layered approach.pptx
 
Lecture W4 CN IP Addressing P1.pptx
Lecture W4 CN IP Addressing P1.pptxLecture W4 CN IP Addressing P1.pptx
Lecture W4 CN IP Addressing P1.pptx
 
W1_Lec01_Lec02_Intro.pptx
W1_Lec01_Lec02_Intro.pptxW1_Lec01_Lec02_Intro.pptx
W1_Lec01_Lec02_Intro.pptx
 

W2_Lec03_Lec_04_Activity.pptx

  • 2. Outline Android UI concepts, What is screen size, what is screen density, what is screen orientation, screen resolution, UI measurement units, density independent pixels, scale independent pixels
  • 3. The Android User Interface Concept What is screen size? • Physical size which is measured along side the diagonal is called screen size. • There are four general sizes small, normal, large and extra large.
  • 4. What is screen density? • Number of pixels in an inch known as dpi (dots per inch) or ppi (pixel per inch). Every Android device has a different density, they just fall broadly into these four categories. There are four main categories. 1. ldpi, 2. mdpi 3. hdpi 4. xhdpi
  • 5. • If you are using pixel as the base unit then the problem is density will be different on the different devices. What happens if you give the actual pixels, and what happens when you give measurements in dpi?
  • 6. • All resources by default are considered for mdpi and scaled by the Android for other configurations. Why screen densities matter the most in Android? • Because you specify the measurements in dp, so Android multiply these with these values for the appropriate device, so you don’t have to worry about how big its going to look on different screens with different densities.
  • 7. What is screen orientation? • Aspect ratio = width / height • Aspect ratio is tall: portrait • Aspect ratio is wide: landscape
  • 8. What is screen resolution? • Number of pixels on the screen is called screen resolution. • In android you should not be concerned with screen resolution, you don’t work with the screen resolution, because it various so much. • There are many device out there and each device has a different screen resolution.
  • 9. • Work only with the screen sizes and screen densities for cross device support.
  • 10. Android User Interface Measurement Units
  • 11. What is density independent pixels? • It is a virtual pixel to define dimensions and position. • You want to say 100dp and don’t want to worry about how big it looks on different screen sizes, you want android to take care how big or appropriate it should look across different devices. • So system converts the dps to pixels when your application runs.
  • 12. • It calculates the pixels out of your specified dps by multiplying that with dot per inch on your device and dividing that by 160.
  • 13. • Android automatically applies the scaling factor for different devices. • Density independent means preserve the physical size of the UI across different devices with different screen densities.
  • 14. What do you get with density independent pixels? • What happens without density independent pixels and what happens with density independent pixels?
  • 15. What are scaled pixels? • It is the same concept as the density independent pixels, but it is only for fonts. • It is virtual pixels scaled according to density and user font preferences.
  • 16. Toast • Toast is nothing more than a message than appears on the screen or activity of your application. • It appears for short durations and then it disappears.
  • 17. Why we use Toast • Giving user feedback regarding some operation. • It doesn’t block the activity or the fragment in which it appears. • It is not like dialog it just appear on the top of your activity and disappears after a short time.
  • 19. How to create Toast Object?
  • 20. • We use static method makeToast() with three parameters. • Context, which is simple way to get resources in Android and to access the system level services for example services like GPS, alarm services, notification services and so on. • So context are the way to those services and you need to pass the context object inside the makeToast() method. • The next is the CharSequence which is simply the text that you want to display. • And at the last is the duration, which can only take two values.
  • 21. • Both are the static fields inside the Toast class. • And after this most important part is to call the show() method with the help of Toast object. • You can display toast even from a service.
  • 25.
  • 26.
  • 27. X and Y distance is relative to Gravity attribute • Remember x and y distance is relative to gravity attribute. If you set gravity to left then it will calculate x and y distance from left. • Similarly if you have set the gravity to center then it will calculate x and y distance from center.
  • 28. • Create a custom layout file.
  • 29. • Make changes in activity_main.xml file.
  • 30. What is an Activity? • All those things which present something to you with which you can interact are called activities in android application development. • Activities are nothing but screens.
  • 32. What activities do? • They draws its user interface (UI) on the screen. • Your application can have many activities but there is only one main activity, just like in C++ there is only one main function, same way your application have only one main activity. • Main activity takes care of launching your application. • An activity can start any other activity belonging to itself. • When a new activity starts, the previous activity stopped and added to a stack known as back-stack.
  • 33. How do I know when Activity is visible to user/paused/stopped? • There are only two things that can happen either user is using your application or user is not using your application. • There should be some kind of way of know whether using is using your activity or not. • This can be achieved by using the special methods called Lifecycle Methods. • These methods tell whether your activity is being used by the user or not, whether your activity is paused or stopped, these methods tell about the current situation of your activity.
  • 34. Why do I need these methods? What do I do with these methods? • These methods simply defines how application behaves.
  • 35. What is call back method? • Android OS calls certain methods on your activity to notify whether your application is running or not.
  • 36. Activity Lifecycle • What happens when user clicks on the application icon? Three methods call. 1. onCreate() 2. onStart() 3. onResume() • What happens when user actually tries to pause your application? 1. onPause() 2. onStop() • What happens when you go back to your application? 1. onRestart() 2. onStart() 3. onResume() • onDestroy() is called when you manually stop your application to free the memory.
  • 37. • When you’ve dialog box which partially blocks your screen, only onPause() is called. • When you’ve something which blocks your whole screen, at that time onPause() and onStop() is called.
  • 38. • When your activity is called. • This is where when your user is attracting with your application. All the attraction comes under this place.
  • 39.
  • 40.
  • 41. • If you go back to your application.
  • 42. • What if you change the orientation of the screen?
  • 44. General Guidelines • Don’t do the heavy processing or network consuming operations when user is currently away from your application. • Application should not crash when another application is started. • Don’t lose the user’s progress or session data.
  • 45. Assignment_03 Create a Toast message by showing any text message on the screen and create Toast to show the message on the different position on screen also show with any image.