Basic android workshop

1,551 views
1,474 views

Published on

Introduction to Android and a walk through of developing a simple android application. http://thagatpam.com

Published in: Technology
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,551
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

Basic android workshop

  1. 1. Developing Applications for Android Platform<br />Jayakumar Palanivel<br />Founder & Director<br />Thagatpam Tech<br />
  2. 2. Agenda<br /><ul><li>Smart phones: Trends, Technology and Market
  3. 3. Why Android
  4. 4. Android Architecture
  5. 5. Developing Applications for Android
  6. 6. Environment
  7. 7. SDK
  8. 8. Market
  9. 9. Sample App</li></li></ul><li>Indian Mobile Internet Market<br />India’s internet users will increase fivefold by 2015, and more than three quarter of them will choose mobile access<br />
  10. 10. Smart Phones: Market<br /><ul><li> Big increase in Smart Phone sales >80million/quarter
  11. 11. > 5Lakhs apps
  12. 12. Huge potential : eBay to make $2billion from sales via mobile channel</li></li></ul><li>Smart Phones: Technology<br /><ul><li> Internet enabled, GPS, Accelerometers, Gyroscopes, Big touch screens => New Application Possibilities
  13. 13. Complete OS(iOS, Android) with Application SDK Support
  14. 14. Smart phones today = PCs two decades ago = Lot of potentials</li></li></ul><li>Android<br /><ul><li>Complete OS for Mobile Internet Handheld devices
  15. 15. From Google and Open Handset Alliance
  16. 16. Free and Open Source, Linux based.
  17. 17. Adapted by many device makers
  18. 18. Application SDK</li></li></ul><li>Why Android<br /><ul><li>Open source and free, hence it will see wider adoption by device makers.
  19. 19. It is already the largest deployed mobile OS for smart phones
  20. 20. Capable of running in Tablets, eBook Readers, etc...
  21. 21. Good community support
  22. 22. It's from Google</li></li></ul><li>Android Architecture<br />
  23. 23. Developing for Android<br /><ul><li>Android provides SDK for Application development
  24. 24. Java
  25. 25. Dalvik VM
  26. 26. Reusable libraries</li></li></ul><li>Development environment<br />Your development environment is preloaded in Ubuntu Virtual Machine<br />
  27. 27. Emulator<br />
  28. 28. Android SDK Model<br />Activities<br />View<br />Services<br />Notifications<br />Content Providers<br />Intents<br />AndroidManifest.xml<br />
  29. 29. Activities<br /><ul><li> Activity manages screens
  30. 30. UI Layout
  31. 31. Lifecycle & Behaviour
  32. 32. Related data
  33. 33. Similar to forms in HTML
  34. 34. Multiple activities can be live
  35. 35. But only one is active and visible</li></li></ul><li>Activity Lifecycle<br />
  36. 36. Views<br /><ul><li> Basic UI building blocks for
  37. 37. Responds to events
  38. 38. Can be grouped as View Trees for creating complex UI
  39. 39. Can be defined in XML – Recommended
  40. 40. Can be defined in program too – Not recommended</li></li></ul><li>Intents<br /><ul><li>Used to move from activities to activities
  41. 41. Provides parameters for the activities to use
  42. 42. Consists of intended action and the data from previous activity.
  43. 43. Similar to request object in HTTP protocol</li></li></ul><li>Services<br /><ul><li> Run in the background
  44. 44. Example : Media player
  45. 45. No user interaction
  46. 46. Used to expose common functionalities to other applications</li></li></ul><li>Notifications<br /><ul><li> Notifies users about different events
  47. 47. SMS Received
  48. 48. New mail arrived
  49. 49. Sent through NotificationManager
  50. 50. Types
  51. 51. Persistent icon
  52. 52. Turning LEDS
  53. 53. Sound or Vibration</li></li></ul><li>Content Providers<br /><ul><li> Persistent data storage mechanism
  54. 54. Store
  55. 55. Retrieve
  56. 56. Only way to make data available across applications
  57. 57. Supports File system or SQLite.
  58. 58. Mostly SQLite
  59. 59. Data exposed as unique URI</li></li></ul><li>The First App : Say Hello<br /><ul><li> Star Eclipse
  60. 60. Create new android project
  61. 61. New -> Project</li></li></ul><li>The First App : Say Hello<br /><ul><li> By default eclipse generates the “Hello Android” application.
  62. 62. Run it by clicking RMB and select “Run as Android Applications”</li></li></ul><li>Application Structure<br /><ul><li> Eclipse generates most of the necessary skeleton
  63. 63. Resources
  64. 64. Icon
  65. 65. Layout
  66. 66. Strings
  67. 67. AndroidManifest.xml
  68. 68. Run configuration</li></li></ul><li>A Real App: MySMS<br />Create a new Android Project<br /><ul><li>Project Name : com.tpm.android.sms
  69. 69. Build Target : Google API 1.6 (API Level 4)
  70. 70. Application Name : MySMS
  71. 71. Package Name : com.tpm.android.sms
  72. 72. Activity : MySMS</li></li></ul><li>Edit Layout<br />- Navigate to res/layout/main.xml<br />- Replace the content with the following<br /><?xmlversion="1.0"encoding="utf-8"?><br /><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"<br />android:orientation="vertical"android:layout_width="fill_parent"<br />android:layout_height="fill_parent"><br /><TextViewandroid:layout_width="wrap_content"<br />android:layout_height="wrap_content"<br />android:text="@string/enter_sms"/><br /><EditTextandroid:id="@+id/body"android:layout_width="fill_parent"<br />android:layout_height="wrap_content"<br />android:scrollbars="vertical"/><br /><Buttonandroid:id="@+id/confirm"<br />android:text="@string/confirm"<br />android:layout_width="wrap_content"<br />android:layout_height="wrap_content"/><br /></LinearLayout><br />
  73. 73. Edit String Resources<br />Open res/values/strings.xml and add the following string resources<br /><stringname="enter_sms">Enter SMS Text</string><br /><stringname="confirm">Send SMS</string><br />
  74. 74. Activity Coding<br />Open src/com.tpm.android.sms/MySMS.java and insert a class member <br />privateEditTextmSmsText;<br />Create a new OnClick Event Listener Class<br />publicclassOnClickListenerimplementsView.OnClickListener {<br /> @OverridepublicvoidonClick(View v) {<br /> String sms = mSmsText.getText().toString();<br />if (sms == null || sms.trim().length() ==0) {<br />Toast.makeText(v.getContext(), <br />"Enter a message", Toast.LENGTH_LONG).show();<br /> } else {<br />Toast.makeText(v.getContext(), <br />"SMS Sent : " + sms , Toast.LENGTH_LONG).show();<br /> }<br />}<br /> }<br />
  75. 75. Activity Coding<br />Edit OnClick Method as shown below<br /> public void onCreate(Bundle savedInstanceState) {<br />super.onCreate(savedInstanceState);<br />setContentView(R.layout.main);<br />mSmsText = (EditText)findViewById(R.id.body);<br /> Button confirmButton = (Button) findViewById(R.id.confirm);<br />confirmButton.setOnClickListener(new OnClickListener());<br /> }<br />Compile and Run. <br />
  76. 76. For on More Android<br />http://developer.android.com<br />Or you can reach us at http://thagatpam.com<br />

×