SlideShare a Scribd company logo
Verious Presents OpenClass – Android Developers Day www.openclass.in Event Organized on September 24, 2011
Agenda Android System Architecture GUI Design Services and Broadcast Receivers Android
Android System Architecture
Linux Kernel Android relies on Linux version 2.6 for core system services such as security, memory management, process management, network stack, and driver model.  New Android specific components have been added Alarm, Android Shared Memory Kernel Memory Killer, Kernel Debugger, Loger
Libraries Android Libraries implementation Android includes a set of C/C++ libraries used by various components of the Android system. These capabilities are exposed to developers through the Android application framework.
Core Libraries System C library  - a BSD-derived implementation of the standard C system library (libc), tuned for embedded Linux-based devices Surface Manager -  Provides a system-wide surface “composer” to render all the surfaces in a frame buffer Can combined 2D and 3D surfaces Can use OpenGL ES and 2D hardware accelerator for its compositions Storage (SQLite)  – a powerful and lightweight relational database engine available to all applications WebKit  – an Application framework that provides foundation for building a web browser.
Core Libraries (Cont..) Media Libraries  - based on PacketVideo's OpenCORE; the libraries support playback and recording of many popular audio and video formats, as well as static image files, including MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG
Android Runtime Android includes a set of core libraries that provides most of the functionality available in the core libraries of the Java programming language. Every Android application runs in its own process, with its own instance of the  Dalvik virtual machine . Dalvik has been written so that a device can run multiple VMs efficiently.  The Dalvik VM executes files in the Dalvik Executable (.dex) format which is optimized for minimal memory footprint The Dalvik VM relies on the Linux kernel for underlying functionality such as threading and low-level memory management.
Application Framework Android offers developers the ability to build extremely rich and innovative applications. Developers are free to take advantage of the device hardware, access location information, run background services, set alarms, add notifications to the status bar, and much, much more. Application Framework Layer Activity Manager  handles application lifecycle Package Manager  holds information about applications loaded in the system Windows Manager  handles all the application related windows View system  provides rich and extensible set of Views that can be used to build an application, including lists, grids, text boxes, buttons, and even an embeddable web browser
Application Framework (Cont..) Resource Manager , providing access to non-code resources such as localized strings, graphics, and layout files Content Providers  that enable applications to access data from other applications (such as Contacts), or to share their own data Notification Manager  that enables all applications to display custom alerts in the status bar Location Manager  that provides location information. Telephony Manager  that provides telephone related events such as incoming/outgoing call
Application Android provides set of core applications including an email client, SMS program, calendar, maps, browser, contacts, and others. All applications are written using the Java programming language.
GUI (Layout) Design
Android UI In an Android application, the user interface is built using View and ViewGroup objects. There are many types of views and view groups, each of which is a descendant of the View class. View objects are the basic units of user interface expression on the Android platform. The View class serves as the base for subclasses called "widgets," which offer fully implemented UI objects, like text fields and buttons. The ViewGroup class serves as the base for subclasses called "layouts," which offer different kinds of layout architecture, like linear, tabular and relative.
View Hierarchy Layouts (Linear/Relative) It can be TextView, Button or any other Widget
Creating a UI Android provides us Facility of creating UI in two ways: 1. Creating XML under Layout directory  2. Create widgets with in Java application
Creating XML under Layout directory  <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?> <LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot; android:layout_width=&quot;fill_parent&quot; android:layout_height=&quot;fill_parent&quot; android:orientation=&quot;vertical&quot; > <TextView android:id=&quot;@+id/text&quot; android:layout_width=&quot;wrap_content&quot; android:layout_height=&quot;wrap_content&quot; android:text=&quot;Hello, I am a TextView&quot; /> <Button android:id=&quot;@+id/button&quot; android:layout_width=&quot;wrap_content&quot; android:layout_height=&quot;wrap_content&quot; android:text=&quot;Hello, I am a Button&quot; /> </LinearLayout>
Create widgets with Java application TextView valueTV = new TextView(this); valueTV.setText(&quot;hallo hallo&quot;); valueTV.setId(5); valueTV.setLayoutParams(new LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
Difference XML Based UI UI created within Application 1. It is easy to create as one can create UI using design tool. No development skill required for this. 2. This helps developer to create consistant UI.  If property of any component is modified in XML then same changes will be reflected everywhere, where component is used. 1. This require testing every time user add any component if developer makes any changes. 2. Developer need to dig into the code and  need to find all usage and replace and test every case as he/she may forget to keep update to same properties everywhere. So its time consming process for developers.
Layout resources in Android One thing that often confuses developers new to the Android platform is the handling of layout resources. The xml files describing the layouts are magically transfered into a more efficient binary format behind the scenes and hidden away - leaving the developer with a static reference to the resources via the R.java file. By using the setContentView(int layoutResId) method of the Activity class your layout will be displayed on the screen. Behind the scenes the Android platform is creating all the view objects contained in your layout xml file provided to the setContentView(int layoutResId) method. This process of creating view objects out of layout resources is referred to as layout inflation.
LayoutInflater To avoid these errors it's a good habit to place the setContentView(int layoutResId) method call at the very top of the onCreate() method. In some cases you will have to do the layout inflation by yourself, i.e. when you want to set a custom view to a Dialog or a Toast. To inflate a view you use the LayoutInflater class. There's a number of different ways to get a handle to a LayoutInflater: LayoutInflater inflater = (LayoutInflater)context.getSystemService( Context.LAYOUT_INFLATER_SERVICE);  OR LayoutInflater inflater = LayoutInflater.from(context); View view  = linflater.inflate(R.layout.inflate_xml, null); TextView tv = (TextView) view.findViewById(R.id.textview_xml); mainLayout.addView(view);
Android Services  and  Broadcast Receiver
Services A service is a component which runs in the background, without interacting with the user. The Android platform provides a lot of pre-defined services, usually exposed via a Manager class. In your activity you access services via the method getSystemService(). Own Services must be declared via the &quot;AndroidManifest.xml&quot;. They run the main thread of their hosting process. Therefore you should run performance intensive tasks in the background .
Own Services  You can declare your own service to perform long running operations without user interaction or to supply functionality to other applications. A activity can start a service via the startService() method and stop the service via the stopService() method. If the activity want to interact with the service it can use the bindService() method of the service. This requires an &quot;ServiceConnection&quot; object which allows to connect to the service and which return a IBinder object. This IBinder object can be used by the activity to communicate with the service. Once a service is started its onCreate() method is called. Afterwards the onStartCommand() is called with the Intent data provided by the activity. startService also allows to provide a flag with determines the lifecycle behavior of the services A Services needs to be declared in the &quot;AndroidManifest.xml&quot; via a <service android:name=&quot;yourclasss&quot;> </service> and the implementing class must extend the class &quot;Service&quot; or one of its subclasses.
Broadcast Receiver  A broadcast receiver is a class which extends &quot;BroadcastReceiver&quot; and which is registered as a receiver in an Android Application via the AndroidManifest.xml (or via code). This class will be able to receive intents via the sendBroadcast() method. &quot;BroadCastReceiver&quot; defines the method &quot;onReceive()&quot;. Only during this method your broadcast receiver object will be valid, afterwards the Android system will consider your object as no longer active. Therefore you cannot perform any asynchronous operation.  AndroidManifest.XML <receiver android:name=&quot;MyPhoneReceiver&quot;>  <intent-filter> <action android:name=&quot;android.intent.action.PHONE_STATE&quot;> </action>  </intent-filter> </receiver>
Broadcast Receiver Example public class MyPhoneReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Bundle extras = intent.getExtras(); if (extras != null) { String state = extras.getString(TelephonyManager.EXTRA_STATE); if (state.equals(TelephonyManager.EXTRA_STATE_RINGING)) { String phoneNumber =  extras.getString(TelephonyManager.EXTRA_INCOMING_NUMBER; Log.w(&quot;DEBUG&quot;, phoneNumber); }  }  }  }

More Related Content

DOCX
Android xml-based layouts-chapter5
PPT
View groups containers
PPTX
PPT
android layouts
PDF
04 user interfaces
PPTX
Android Workshop: Day 1 Part 3
PDF
Android ui layout
PDF
Training android
Android xml-based layouts-chapter5
View groups containers
android layouts
04 user interfaces
Android Workshop: Day 1 Part 3
Android ui layout
Training android

What's hot (19)

PDF
Android Screen Containers & Layouts
PPTX
Android Tutorials : Basic widgets
PPT
Day: 2 Environment Setup for Android Application Development
PPT
Android Bootcamp Tanzania:understanding ui in_android
PPTX
Android application-component
PPT
Multiple Activity and Navigation Primer
PDF
AndroidManifest
PPT
Londroid Android Home Screen Widgets
PPTX
Android Widget
PPT
Android
PDF
Android layouts
PDF
Android Basic- CMC
PPT
Android tutorial
PPT
Android tutorial
PPT
Android tutorial
PDF
Ui layout (incomplete)
PPTX
Android apps development
PDF
01 11 - graphical user interface - fonts-web-tab
Android Screen Containers & Layouts
Android Tutorials : Basic widgets
Day: 2 Environment Setup for Android Application Development
Android Bootcamp Tanzania:understanding ui in_android
Android application-component
Multiple Activity and Navigation Primer
AndroidManifest
Londroid Android Home Screen Widgets
Android Widget
Android
Android layouts
Android Basic- CMC
Android tutorial
Android tutorial
Android tutorial
Ui layout (incomplete)
Android apps development
01 11 - graphical user interface - fonts-web-tab
Ad

Similar to Android Tutorial (20)

PPTX
Technology and Android.pptx
DOCX
Android Tutorial For Beginners Part-1
PDF
Android App development and test environment, Understaing android app structure
PDF
Android tutorial
PPT
android training_material ravy ramio
PPTX
PPT
Industrial Training in Android Application
PPTX
Android apps development
PPTX
Android Development : (Android Studio, PHP, XML, MySQL)
PPT
Intro to Android Programming
KEY
Android Workshop
PDF
Mobile Application Development -Lecture 07 & 08.pdf
PPT
Getting started with android dev and test perspective
PPTX
Introduction To Google Android (Ft Rohan Bomle)
PPT
Android Presentation for fundamental.ppt
PDF
Training Session 2 - Day 2
PPTX
Android App Development (Basics)
PPT
Android In A Nutshell
PPT
PPT Companion to Android
ODP
Android training day 2
Technology and Android.pptx
Android Tutorial For Beginners Part-1
Android App development and test environment, Understaing android app structure
Android tutorial
android training_material ravy ramio
Industrial Training in Android Application
Android apps development
Android Development : (Android Studio, PHP, XML, MySQL)
Intro to Android Programming
Android Workshop
Mobile Application Development -Lecture 07 & 08.pdf
Getting started with android dev and test perspective
Introduction To Google Android (Ft Rohan Bomle)
Android Presentation for fundamental.ppt
Training Session 2 - Day 2
Android App Development (Basics)
Android In A Nutshell
PPT Companion to Android
Android training day 2
Ad

More from Fun2Do Labs (16)

PDF
Startup Canvas - Guide for a new entrepreneur
PDF
Fun2Do Labs : Educating Maker Kids in India
PDF
Maker Education : Bob the Robot
PDF
Maker Education : Building a Toy Car with Arduino
PDF
Maker Education : Toy Lamp
PDF
Building a Toy Car
PDF
What is a Makerspace?
PDF
Using Arduino
PDF
Transmedia in Open Education
PDF
How to Solder?
PDF
Toy Fan Project in School Makerspace
PDF
Maker Education - Making Toy LED Glow
PDF
Fun2Do Labs - Open Education Project
PPTX
Mig33 Developer Program
PPTX
OpenClass - Social Gaming
PPTX
OpenClass - What is Java ME - J2ME
Startup Canvas - Guide for a new entrepreneur
Fun2Do Labs : Educating Maker Kids in India
Maker Education : Bob the Robot
Maker Education : Building a Toy Car with Arduino
Maker Education : Toy Lamp
Building a Toy Car
What is a Makerspace?
Using Arduino
Transmedia in Open Education
How to Solder?
Toy Fan Project in School Makerspace
Maker Education - Making Toy LED Glow
Fun2Do Labs - Open Education Project
Mig33 Developer Program
OpenClass - Social Gaming
OpenClass - What is Java ME - J2ME

Recently uploaded (20)

PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
Machine Learning_overview_presentation.pptx
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Getting Started with Data Integration: FME Form 101
PDF
Empathic Computing: Creating Shared Understanding
PPTX
A Presentation on Artificial Intelligence
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPTX
1. Introduction to Computer Programming.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PPTX
Spectroscopy.pptx food analysis technology
NewMind AI Weekly Chronicles - August'25-Week II
Diabetes mellitus diagnosis method based random forest with bat algorithm
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Machine Learning_overview_presentation.pptx
gpt5_lecture_notes_comprehensive_20250812015547.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Getting Started with Data Integration: FME Form 101
Empathic Computing: Creating Shared Understanding
A Presentation on Artificial Intelligence
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
1. Introduction to Computer Programming.pptx
Spectral efficient network and resource selection model in 5G networks
Building Integrated photovoltaic BIPV_UPV.pdf
MYSQL Presentation for SQL database connectivity
Digital-Transformation-Roadmap-for-Companies.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation
Advanced methodologies resolving dimensionality complications for autism neur...
Assigned Numbers - 2025 - Bluetooth® Document
Spectroscopy.pptx food analysis technology

Android Tutorial

  • 1. Verious Presents OpenClass – Android Developers Day www.openclass.in Event Organized on September 24, 2011
  • 2. Agenda Android System Architecture GUI Design Services and Broadcast Receivers Android
  • 4. Linux Kernel Android relies on Linux version 2.6 for core system services such as security, memory management, process management, network stack, and driver model. New Android specific components have been added Alarm, Android Shared Memory Kernel Memory Killer, Kernel Debugger, Loger
  • 5. Libraries Android Libraries implementation Android includes a set of C/C++ libraries used by various components of the Android system. These capabilities are exposed to developers through the Android application framework.
  • 6. Core Libraries System C library - a BSD-derived implementation of the standard C system library (libc), tuned for embedded Linux-based devices Surface Manager - Provides a system-wide surface “composer” to render all the surfaces in a frame buffer Can combined 2D and 3D surfaces Can use OpenGL ES and 2D hardware accelerator for its compositions Storage (SQLite) – a powerful and lightweight relational database engine available to all applications WebKit – an Application framework that provides foundation for building a web browser.
  • 7. Core Libraries (Cont..) Media Libraries - based on PacketVideo's OpenCORE; the libraries support playback and recording of many popular audio and video formats, as well as static image files, including MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG
  • 8. Android Runtime Android includes a set of core libraries that provides most of the functionality available in the core libraries of the Java programming language. Every Android application runs in its own process, with its own instance of the Dalvik virtual machine . Dalvik has been written so that a device can run multiple VMs efficiently. The Dalvik VM executes files in the Dalvik Executable (.dex) format which is optimized for minimal memory footprint The Dalvik VM relies on the Linux kernel for underlying functionality such as threading and low-level memory management.
  • 9. Application Framework Android offers developers the ability to build extremely rich and innovative applications. Developers are free to take advantage of the device hardware, access location information, run background services, set alarms, add notifications to the status bar, and much, much more. Application Framework Layer Activity Manager handles application lifecycle Package Manager holds information about applications loaded in the system Windows Manager handles all the application related windows View system provides rich and extensible set of Views that can be used to build an application, including lists, grids, text boxes, buttons, and even an embeddable web browser
  • 10. Application Framework (Cont..) Resource Manager , providing access to non-code resources such as localized strings, graphics, and layout files Content Providers that enable applications to access data from other applications (such as Contacts), or to share their own data Notification Manager that enables all applications to display custom alerts in the status bar Location Manager that provides location information. Telephony Manager that provides telephone related events such as incoming/outgoing call
  • 11. Application Android provides set of core applications including an email client, SMS program, calendar, maps, browser, contacts, and others. All applications are written using the Java programming language.
  • 13. Android UI In an Android application, the user interface is built using View and ViewGroup objects. There are many types of views and view groups, each of which is a descendant of the View class. View objects are the basic units of user interface expression on the Android platform. The View class serves as the base for subclasses called &quot;widgets,&quot; which offer fully implemented UI objects, like text fields and buttons. The ViewGroup class serves as the base for subclasses called &quot;layouts,&quot; which offer different kinds of layout architecture, like linear, tabular and relative.
  • 14. View Hierarchy Layouts (Linear/Relative) It can be TextView, Button or any other Widget
  • 15. Creating a UI Android provides us Facility of creating UI in two ways: 1. Creating XML under Layout directory 2. Create widgets with in Java application
  • 16. Creating XML under Layout directory <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?> <LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot; android:layout_width=&quot;fill_parent&quot; android:layout_height=&quot;fill_parent&quot; android:orientation=&quot;vertical&quot; > <TextView android:id=&quot;@+id/text&quot; android:layout_width=&quot;wrap_content&quot; android:layout_height=&quot;wrap_content&quot; android:text=&quot;Hello, I am a TextView&quot; /> <Button android:id=&quot;@+id/button&quot; android:layout_width=&quot;wrap_content&quot; android:layout_height=&quot;wrap_content&quot; android:text=&quot;Hello, I am a Button&quot; /> </LinearLayout>
  • 17. Create widgets with Java application TextView valueTV = new TextView(this); valueTV.setText(&quot;hallo hallo&quot;); valueTV.setId(5); valueTV.setLayoutParams(new LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
  • 18. Difference XML Based UI UI created within Application 1. It is easy to create as one can create UI using design tool. No development skill required for this. 2. This helps developer to create consistant UI. If property of any component is modified in XML then same changes will be reflected everywhere, where component is used. 1. This require testing every time user add any component if developer makes any changes. 2. Developer need to dig into the code and need to find all usage and replace and test every case as he/she may forget to keep update to same properties everywhere. So its time consming process for developers.
  • 19. Layout resources in Android One thing that often confuses developers new to the Android platform is the handling of layout resources. The xml files describing the layouts are magically transfered into a more efficient binary format behind the scenes and hidden away - leaving the developer with a static reference to the resources via the R.java file. By using the setContentView(int layoutResId) method of the Activity class your layout will be displayed on the screen. Behind the scenes the Android platform is creating all the view objects contained in your layout xml file provided to the setContentView(int layoutResId) method. This process of creating view objects out of layout resources is referred to as layout inflation.
  • 20. LayoutInflater To avoid these errors it's a good habit to place the setContentView(int layoutResId) method call at the very top of the onCreate() method. In some cases you will have to do the layout inflation by yourself, i.e. when you want to set a custom view to a Dialog or a Toast. To inflate a view you use the LayoutInflater class. There's a number of different ways to get a handle to a LayoutInflater: LayoutInflater inflater = (LayoutInflater)context.getSystemService( Context.LAYOUT_INFLATER_SERVICE); OR LayoutInflater inflater = LayoutInflater.from(context); View view = linflater.inflate(R.layout.inflate_xml, null); TextView tv = (TextView) view.findViewById(R.id.textview_xml); mainLayout.addView(view);
  • 21. Android Services and Broadcast Receiver
  • 22. Services A service is a component which runs in the background, without interacting with the user. The Android platform provides a lot of pre-defined services, usually exposed via a Manager class. In your activity you access services via the method getSystemService(). Own Services must be declared via the &quot;AndroidManifest.xml&quot;. They run the main thread of their hosting process. Therefore you should run performance intensive tasks in the background .
  • 23. Own Services You can declare your own service to perform long running operations without user interaction or to supply functionality to other applications. A activity can start a service via the startService() method and stop the service via the stopService() method. If the activity want to interact with the service it can use the bindService() method of the service. This requires an &quot;ServiceConnection&quot; object which allows to connect to the service and which return a IBinder object. This IBinder object can be used by the activity to communicate with the service. Once a service is started its onCreate() method is called. Afterwards the onStartCommand() is called with the Intent data provided by the activity. startService also allows to provide a flag with determines the lifecycle behavior of the services A Services needs to be declared in the &quot;AndroidManifest.xml&quot; via a <service android:name=&quot;yourclasss&quot;> </service> and the implementing class must extend the class &quot;Service&quot; or one of its subclasses.
  • 24. Broadcast Receiver A broadcast receiver is a class which extends &quot;BroadcastReceiver&quot; and which is registered as a receiver in an Android Application via the AndroidManifest.xml (or via code). This class will be able to receive intents via the sendBroadcast() method. &quot;BroadCastReceiver&quot; defines the method &quot;onReceive()&quot;. Only during this method your broadcast receiver object will be valid, afterwards the Android system will consider your object as no longer active. Therefore you cannot perform any asynchronous operation. AndroidManifest.XML <receiver android:name=&quot;MyPhoneReceiver&quot;> <intent-filter> <action android:name=&quot;android.intent.action.PHONE_STATE&quot;> </action> </intent-filter> </receiver>
  • 25. Broadcast Receiver Example public class MyPhoneReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Bundle extras = intent.getExtras(); if (extras != null) { String state = extras.getString(TelephonyManager.EXTRA_STATE); if (state.equals(TelephonyManager.EXTRA_STATE_RINGING)) { String phoneNumber = extras.getString(TelephonyManager.EXTRA_INCOMING_NUMBER; Log.w(&quot;DEBUG&quot;, phoneNumber); } } } }