Introduction to Android Programming

179 views

Published on

Android is an open source and Linux-based operating system for mobile devices such as smartphones and tablet computers. Android was developed by the Open Handset Alliance, led by Google, and other companies. This tutorial will teach you basic Android programming and will also take you through some advance concepts related to Android application development.

Published in: Education
1 Comment
1 Like
Statistics
Notes
No Downloads
Views
Total views
179
On SlideShare
0
From Embeds
0
Number of Embeds
92
Actions
Shares
0
Downloads
6
Comments
1
Likes
1
Embeds 0
No embeds

No notes for slide

Introduction to Android Programming

  1. 1. Agenda ● Introduction ● Android Components overview ● Sample Application ● Android Software Stack ● Android Components detailed – Activity, Service, Provider, Receiver
  2. 2. History of Android • Android, Inc. – 2003 • Operating system for digital cameras • Google Acquisition – 2005 • Open Handset Alliance – Nov 2007 –  Google, HTC, Sony and Samsung – Qualcomm and Texas Instruments •  HTC Dream - October 22, 2008
  3. 3. Android Application Components
  4. 4. Application Components • Application components are the essential building blocks of an Android application.
  5. 5. Application components ● Activity ● Service ● Broadcast Receiver ● Content Provider
  6. 6. Application components
  7. 7. Activities • An activity represents a single screen with a user interface • Example of Activities in Email app – Email List – Compose – Read
  8. 8. Activities
  9. 9. Services • A service is a component that runs in the background • A service does not provide a user interface. • Example : Music Player, Downloader
  10. 10. Services
  11. 11. Content Provider • Content provider – Allows to share data with other apps •
  12. 12. Content Provider
  13. 13. Content Provider
  14. 14. Broadcast Receiver ● Listener of System wide events. ● Examples – SMS received , Wifi / Bluetooth connected – Battery Low, Device Rebooted ● No UI ● Lightweight ( < 10 seconds )
  15. 15. Intents IntentsIntents Intents are messages across components. Like Hyperlinks on the web
  16. 16. Intents ● Support interaction between components – e.g. Start a new Activity – Broadcast messages ● Intents : request for action to be performed
  17. 17. 17 Types of Intents MyApp Activity1 Service1Intent ( myService.class ) OtherAppMyApp Activity1 Activity2 Explicit Intent Implicit IntentIntent ( “ACTION” ) Intents
  18. 18. Intents start new Activity ● Dial a number Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse(“tel:97412345”)); ● Launch a website Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(“http://www.google.com”));
  19. 19. Intents start new Activity ● Launch another activity Intent i = new Intent(this, SecondActivity.class) startActivity(i)
  20. 20. Intent Filter ● Registers components as capable of receiving Intents ● Matches intents to the component (Activity , Service, Receivers) ● Declared mostly in AndroidManifest.xml
  21. 21. Functional Android App
  22. 22. <?xml version="1.0" encoding="utf-8"?> <manifest> <uses-permission /> <uses-sdk /> <application> <activity> </activity> </application> </manifest> Application Manifest File
  23. 23. <?xml version="1.0" encoding="utf-8"?> <LinearLayout> <TextView android:text="I am a TextView" /> <Button android:text="I am a Button" /> </LinearLayout> XML Snippet
  24. 24. Preview
  25. 25. Layouts • Linear Layout • Relative Layout • List View • Grid View
  26. 26. Linear Layout <?xml version="1.0" encoding="utf-8"?> <LinearLayout android:orientation="vertical" > <TextView android:text="I am a TextView" /> <Button android:text="I am a Button" /> </LinearLayout>
  27. 27. Linear Layout <?xml version="1.0" encoding="utf-8"?> <LinearLayout android:orientation=“horizontal" > <TextView android:text="I am a TextView" /> <Button android:text="I am a Button" /> </LinearLayout>
  28. 28. Layouts Grid ViewList View
  29. 29. UI Widgets
  30. 30. Sample App <Button android:id="@+id/my_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text=“I am a Button"/> Button myButton =(Button)findViewById(R.id.my_button);
  31. 31. Sample App public void (View v) { // action } Add this in XML file android:onClick="myMethod"
  32. 32. Sample App ● Extend this to create SecondActivity ● invoked on clicking the button
  33. 33. Inside the APK ● Compiled Java source ● Libraries ● XML files for UI, strings ● Resources – Images etc ● Android Manifest
  34. 34. Android Software Stack ● Kernel ● Libraries / Runtime ● Application Framework ● Applications
  35. 35. Android Software Stack
  36. 36. Linux kernel • Android built on Linux 2.6 kernel • Provides security, memory management, process management, network stack, and driver model • Abstraction layer between hardware and the software stack
  37. 37. Libraries • A set of C/C++ libraries exposed to developers through the application framework
  38. 38. Application Framework
  39. 39. Application Framework
  40. 40. Applications
  41. 41. Summary ● Android Components ● Android Sample Program ● Activity, Services, Broadcast Receiver ● Intents ● Android Stack
  42. 42. Contact arvindd@belimitless.co http://belimitless.co

×