Your SlideShare is downloading. ×
Android Programming Basic
Android Programming Basic
Android Programming Basic
Android Programming Basic
Android Programming Basic
Android Programming Basic
Android Programming Basic
Android Programming Basic
Android Programming Basic
Android Programming Basic
Android Programming Basic
Android Programming Basic
Android Programming Basic
Android Programming Basic
Android Programming Basic
Android Programming Basic
Android Programming Basic
Android Programming Basic
Android Programming Basic
Android Programming Basic
Android Programming Basic
Android Programming Basic
Android Programming Basic
Android Programming Basic
Android Programming Basic
Android Programming Basic
Android Programming Basic
Android Programming Basic
Android Programming Basic
Android Programming Basic
Android Programming Basic
Android Programming Basic
Android Programming Basic
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Android Programming Basic

1,256

Published on

0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,256
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
4
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • Section divider 1
  • Slide text 2
  • Slide text 2
  • Slide text 2
  • Slide text 2
  • Slide text 2
  • Slide text 2
  • Slide text 2
  • Slide text 2
  • Slide text 2
  • Slide text 2
  • Slide text 2
  • Slide text 2
  • Slide text 2
  • Slide text 2
  • Slide text 2
  • Slide text 2
  • Slide text 2
  • Slide text 2
  • Slide text 2
  • Slide text 2
  • Slide text 2
  • Slide text 2
  • Slide text 2
  • Slide text 2
  • Slide text 2
  • Slide text 2
  • Slide text 2
  • Section divider 1
  • Transcript

    • 1. Android ProgrammingBasic
    • 2. AgendaIntroducing Android• What is android?• Android architecture• Installing the tools• Creating first programAndroid basic• Layout• Custom component• Menu• Dialog• Supporting Multiple Screens• Activity• Google map• Location services• Using sensors• Communicating with the server• Working in the background
    • 3. Introducing android
    • 4. What is android?Android is a Linux-based mobile phone operating system developedby Google•Open•All application are created equal•Breaking down application boundaries•Fast & easy application development
    • 5. What is android? Source: An introduction to android – Huang Xuguang
    • 6. What is android?U.S. Smartphone Market share
    • 7. Android architecture Source: http://developer.android.com
    • 8. Installing the toolsJava SE (JDK)EclipseAndroid SDKAndroid Development Tools (ADT) for EclipseAndroid platforms and other componentsCreate virtual device
    • 9. Creating first program
    • 10. Android basic
    • 11. Layout• Linear Layout• Frame Layout• Absolute Layout• Relative Layout• Table Layout
    • 12. Custom ComponentExtend an existing View classOverride some of the methods from the superclass• onDraw: Called when the view should render its content.• onMeasure: Called to determine the size requirements for this view and all of its children.• onTouchEvent, onKeyUp, onKeyDown …
    • 13. Custom componentUse the Custom Component
    • 14. Menu• Options Menu: The primary collection of menu items for an activity, which appears when the user touches the MENU button.• Context Menu: A floating list of menu items that appears when the user touches and holds a view thats registered to provide a context menu.• Sub Menu: A floating list of menu items that appears when the user touches a menu item that contains a nested menu.
    • 15. Dialog• Alert Dialog• Progress Dialog• Date Picker Dialog• Time Picker Dialog• Custom Dialog Source: http://developer.android.com
    • 16. Supporting Multiple ScreensDisplay units in android• dp: Density-independent Pixels - an abstract unit that is based on the physical density of the screen. These units are relative to a 160 dpi (dots per inch) screen, so 160dp is always one inch regardless of the screen density The conversion of dp units to screen pixels is simple: px = dp * (dpi / 160). For example, on a 160 dpi screen, 1 dp equals 1 physical pixels and on a 240 dpi screen, 1 dp equals 1.5 physical pixels…• sp: Scale-independent Pixels - this is like the dp unit, but it is also scaled by the users font size preference.• pt: Points - 1/72 of an inch based on the physical size of the screen• px: Pixels - corresponds to actual pixels on the screen• mm: Millimeters - based on the physical size of the screen.• in: Inches - based on the physical size of the screen. Source: http://developer.android.com
    • 17. Supporting Multiple Screens Density independenceExample application without support for different densities, as shown on low, medium, and high density screens.Example application with good support for different densities (its density independent), as shown on low, medium, and high densityscreens. Source: http://developer.android.com
    • 18. Supporting Multiple ScreensUsing configuration qualifiers• Directory qualifier Size: small, normal, large, xlarge Density: ldpi (~120dpi), mdpi (~160dpi), hdpi (~240dpi), xhdpi, nodpi, tvdpi Aspect ratio: long, notlong Orientation: land, port• List of resource directory• Specific screen size (via the AndroidManifest) Source: http://developer.android.com
    • 19. Supporting Multiple ScreensNinePatch Source: http://www.developer.com/ws/other/article.php/3889086/Working- with-NinePatch-Stretchable-Graphics-in-Android.htm
    • 20. Supporting Multiple ScreensDraw 9-patch Source: http://android10.org/index.php/articlesother/279-draw-9-patch-tutorial
    • 21. Activity• An Activity roughly corresponds to screen• They appear on a stack, with one visible at a time, and use a BACK button for reverse navigation through the stack
    • 22. ActivityActivity Lifecycle
    • 23. ActivityNavigating to another activityWait for result
    • 24. ActivityPassing data to another activitySharing data among activities• using a class with a lot of static variables• File or database
    • 25. Google map
    • 26. Location servicesCell ID• Each cell tower worldwide has a unique identifier called Cell ID• Each tower knows its latitude and longitude, so its easy enough for a mobile phone to know "approximately" where you are locatedTriangulation• Most of the time your mobile phone is in range of more than one cell tower• The cell tower has the ability to tell what direction your signal is coming from• If there are two or three towers that can see your phone, together they can triangulate on your phones locationGPS• The satellite-based Global Positioning System (GPS)• Your mobile phone can determine its location very accurately Source: http://www.helloandroid.com/content/location-and-mapping
    • 27. Using sensorsAndroid supports several sensors via the SensorManager• Accelerometer• Compass• Temperature• Gyroscope• Gravity• Proximity• …Can not test on the Android emulator
    • 28. Communicating with the server• HttpGet• HttpPost• Socket• Call webservice using ksoap2
    • 29. Working in the backgroundThreads• Android supports standart Java Threads.• If you need update the UI in a separate thread you need to use Handler (android.os.Handler). When you send message to the Handler and it will get saved into a queue and get executed by the UI thread as soon as possible.Handler• The class "Handler" can update the UI.
    • 30. Working in the backgroundAsyncTask• The class AsyncTask encapsulates the creation of Threads and Handlers• AsyncTask enables proper and easy use of the UI thread• An asynchronous task is defined by 3 generic types, called Params, Progress and Result, and 4 steps, called onPreExecute, doInBackground, onProgressUpdate and onPostExecute.• Example:
    • 31. References• Thesis - Android programming – Vo Thanh Nhat & Phan Thanh Trung – University of Science Ho Chi Minh City• Hello android – Introducing Google Mobile’s Development Platform – Ed Burnette• Wrox – Professional Android Application development – Rito Meier• Wrox – Professional Android 2 Application development – Rito Meier• Apress – Pro Android – Sayed Y.Hashimi and Satya Komatineni• http://developer.android.com• http://stackoverflow.com• http://www.helloandroid.com• …
    • 32. Slide, tools, documents &samplesShare on my PC now: yp-tienhungandroid
    • 33. Q&A

    ×