Introducing mobile application development for android 20 5-2011
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
1,184
On Slideshare
1,179
From Embeds
5
Number of Embeds
2

Actions

Shares
Downloads
40
Comments
0
Likes
0

Embeds 5

http://www.linkedin.com 4
https://www.linkedin.com 1

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

Transcript

  • 1. Introducing Mobile Application Development for Android Presented by: Ahmed Misbah
  • 2. AgendaIntroductionAndroid SDK FeaturesDeveloping an Android ApplicationAndroid MarketAndroid Application Trends
  • 3. INTRODUCTION
  • 4. What is Android?Google’s mobile operating systemBased on Linux KernelOffers an SDK and NDKLatest SDK version is 3.0/3.1 (Honeycomb)
  • 5. Architecture Overview
  • 6. Linux KernelAndroid uses Linux Kernel for: Hardware Abstraction Layer (HAL) Memory management Process management Networking
  • 7. Native LibrariesShared libraries all written in C or C++Compiled for the particular hardwarearchitecture used by the phonePreinstalled by the phone vendorCan be developed using NDK
  • 8. Important Native LibrariesSurface Manager2D Graphics (SGL)3D Graphics (OpenGl ES)Media Codecs (ex. AAC, AVC(H.264), H.263,MP3 and MPEG-4)SQL Database (SQLite)Browser Engine (WebKit)
  • 9. Android RuntimeDalvik VM Google’s implementation of Java Optimized for mobile devices Runs .dex files which are more compact and efficient than standard .class filesCore Java libraries Not those of JSE or JME but have some similarities
  • 10. Application FrameworkActivity ManagerContent ProvidersWindow ManagerResource ManagerLocation ManagerNotification Manager
  • 11. Application Lifecycle
  • 12. Building BlocksActivities : User InterfaceIntent: A mechanism for describing a specificactionService: A task that runs in the backgroundwithout user interactionContent Providers: is a set of data wrapped upin a custom API to read and write it
  • 13. Application Structure
  • 14. ResourcesStored in res folderIncludes all non code information (e.g.localized text and images)Resources compiler compresses and packs allresources in a class named R
  • 15. Difference between Assets and ResourcesWith resources, you would have to declare alist of all the resource IDs that might be usedand compute an index into the listAssets can be organized into a folderhierarchy, which is not supported by resources
  • 16. Android ManifestEvery application must have anAndroidManifest.xml file in its root directoryManifest presents essential information aboutthe application to the Android system: Java package Components of the application (Activities, Services, etc.) Permissions the application Minimum level of the Android Libraries that the application utilizes
  • 17. SecurityStored in Android-Manifest.xmlContains following permissions: INTERNET READ_CONTACTS WRITE_CONTACTS RECEIVE_SMS ACCESS_COARSE_LOCATION ACCESS_FINE_LOCATION WRITE_EXTERNAL_STORAGE
  • 18. ANDROID SDK FEATURES
  • 19. Android SDK FeaturesUser InterfaceGraphicsMultimediaData StorageNetworkingLocating and SensingTelephony, Messaging and NotificationI18N and Localization
  • 20. USER INTERFACE
  • 21. Declaring LayoutDeclare UI elements in XMLInstantiate layout elements at runtime
  • 22. Activity ClassActivity class takes care of creating a windowin which UI can be placedThere is a one-to-one relationship between anActivity and a UI screenActivities are made up of subcomponentscalled Views
  • 23. ViewsViews are what your users will see andinteract with
  • 24. Views (cont’d)
  • 25. Views (cont’d)
  • 26. Views (cont’d)
  • 27. ResourcesSome important resource files /res/layout/main.xml /res/layout-land/main.xml /res/values/strings.xml /res/values/colors.xml /res/values/styles.xml /res/menu/menu.xml
  • 28. LayoutsLayouts are defined in /res/layout/main.xmlLayouts are automatically converted to amember in the layout inner class in R class
  • 29. Layouts (cont’d)Linear Layout: Arranges its children in a singlecolumn or row. This is the most commonlayout you will use
  • 30. Layouts(cont’d)Relative Layout: Arranges its children inrelation to each other or to the parent. This isoften used in forms
  • 31. Layouts(cont’d)Table Layout: Arranges its children in rows andcolumns, similar to an HTML table
  • 32. Tab Activity
  • 33. ListenersTell Android which object to callback when theuser touches or clicks the viewUse setOnClickListener() method that needs tobe passed an object that implements theOnClickListener Java interfaceSet android:onClick property with the methodname that handles the click action
  • 34. Applying a ThemeAndroid is packaged with several themes thatyou can reference by name, or you can makeup your own theme by extending existing onesand overriding their default valuesYou can define your own custom theme inres/values/styles.xml
  • 35. MenusAndroid supports three kinds of menus: Options Menu: the menu you get when you press the physical Menu button Context Menu: that pops up when you press and hold your finger on the screen Sub Menu: a floating list of menu items that the user opens by pressing a menu
  • 36. Menus (cont’d)
  • 37. DialogsA small window that appears in front of thecurrent Activity
  • 38. Search Activity
  • 39. GRAPHICS
  • 40. OverviewAndroid provides a powerful graphics librarythat supports drawing of 2D shapes anddeveloping animations2D Graphics since version 3.0 can also behardware acceleratedFor 3D Graphics, android provides animplementation based on OpenGL ES 1.0 APIs
  • 41. 2D GraphicsAndroid offers a custom 2D graphics library fordrawing and animating shapes and imagesThe android.graphics.drawable andandroid.view.animation packages are whereyoull find the common classes used fordrawing and animating in two-dimensions
  • 42. Drawable classA Drawable is a general abstraction for“something that can be drawn.”Subclasses include BitmapDrawable,ShapeDrawable, PictureDrawable, etc.draw method takes a Canvas which handlesdrawing of primitive shapes (Bitmap,rectangle, line, circle, etc.)
  • 43. AnimationsAndroid support 2 animation frameworks: Property Animation: latest animation framework that allows developers to animate almost anything View Animation: provides the capability to only animate View objects
  • 44. Property AnimationAvailable since version 3.0Changes a propertys (a field in an object)value over a specified length of time
  • 45. View AnimationTween Animation: can perform a series ofsimple transformations (position, size, rotation,and transparency) on the contents of a ViewobjectFrame Animation: a traditional animation in thesense that it is created with a sequence ofdifferent images, played in order, like a roll offilm
  • 46. Live WallpaperIntroduced in version 2.1Like any normal application, can use anyfeature (MapView, Accelerometer, GPS, …)Provides an Engine for handling rendering ofWallpaperProvide “settings screen”
  • 47. MULTIMEDIA
  • 48. AudioSteps for playing Audio:1. Put sound files in res/raw directory2. Create android.media.MediaPlayer instance3. mediaPlayer.start() • stop(), pause(), reset(), prepare(), setLooping(), …Useful methods: setVolumeControlStream(AudioManager.STREA M_MUSIC) setOnCompletionListener( )
  • 49. VideoExactly similar to Audio MediaPlayer => start(), stop() Just add “Surface” to preview the videoOr simply use VideoView: video.setVideoPath("/data/samplevideo.3gp" ); video.start();
  • 50. DATA STORAGE
  • 51. PreferencesAllows reading and writing applicationpreferences using Key and ValueAccessible through SharedPreferences class
  • 52. Preference ActivityOut of the box preference screenPreference screen components declared inXMLPreference screen loaded from class whichextends PreferenceActivity
  • 53. Accessing Internal File SystemAllows access to package private directorycreated at install time(/data/data/packagename)Few helper methods are provided on theContext: deleteFile( ) fileList( ) openFileInput( ) openFileOutput( )
  • 54. Accessing SD Card Requires WRITE_EXTERNAL_STORAGE permission Uses /sdcard/ instead of /data/// Load and start the movievideo.setVideoPath("/sdcard/samplevideo.3gp" );video.start(); Use standard java.io to access files
  • 55. Database accessAndroid utilizes SQLiteA SQLite database is just a single fileAndroid stores the file in the/data/data/packagename/databasesdirectoryUses standard SQL DML and DDL scripts
  • 56. Database access (cont’d)DB is accessible through a class that extendsSQLiteOpenHelperProvides an object of SQLiteDatabase that exposesmethods like: db.execSQL(String sql) db.insert(String tablename, String nullColumnHack, ContentValues values); db.query (String table, String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy, String limit)
  • 57. Database access (cont’d)query methods returns an object of Cursorclass over a result setData binding is possible using ListActivity
  • 58. BREAK
  • 59. NETWORKING
  • 60. Connectivity ManagerMonitor network connections (Wi-Fi, GPRS,UMTS, etc.)Send broadcast intents when networkconnectivity changesAttempt to "fail over" to another networkwhen connectivity to a network is lostProvide an API that allows applications toquery the coarse-grained or fine-grained stateof the available networks
  • 61. SocketsSimilar to JSE socket programming
  • 62. Bluetooth SocketRequires permissionandroid.permission.BLUETOOTHSetting up Bluetooth: Enabling Bluetooth Finding Paired Devices Searching for Devices Enabling Discoverability
  • 63. Bluetooth Socket (cont’d)You can connect as a Server usingBluetoothServerSocketYou can also connect as a client usingBluetoothDevice and BluetoothSocketConnections are managed by BluetoothSocketusing InputStream and OutputStream
  • 64. Working with HTTP Similar to JSE using HttpURLConnection and java.net Robust HTTP with HttpClientHttpClient httpclient = new DefaultHttpClient();HttpPost httppost = new HttpPost("http://www.website.org/service.php");List<NameValuePair> pairs = new ArrayList<NameValuePair>(2);pairs.add(new BasicNameValuePair("ID", "VALUE"));httppost.setEntity(new UrlEncodedFormEntity(pairs));HttpResponse webServerAnswer = httpclient.execute(httppost);
  • 65. Working with Web ServicesSOAP Web Services can be invoked using 3rdparty library such as org.ksoap2RESTful Web Service can be implementedusing HttpURLConnection and XML parserand/or JSON library
  • 66. LOCATING AND SENSING
  • 67. Locating OverviewSupported Providers: GPS Cell Towers WI-FIAccess to location information is protected byAndroid permissions: ACCESS_COARSE_LOCATION ACCESS_FINE_LOCATION
  • 68. Location ManagerProvides access to the system locationservicesRetrieved throughContext.getSystemService(Context.LOCATION_SERVICE)
  • 69. Location Manager(cont’d)Useful Methods: getAllProviders() getBestProvider(Criteria criteria, boolean enabledOnly) getLastKnownLocation(String provider) requestLocationUpdates(String provider, long minTime, float minDistance, LocationListener listener)
  • 70. Location ListenerUsed for receiving notifications from theLocationManager when the location isupdatedLocation Listener methods: onLocationChanged(Location location) onProviderDisabled(String provider) onProviderEnabled(String provider) onStatusChanged(String provider, int status, Bundle extras)
  • 71. GeocodingThe process of finding associated geographiccoordinates (often expressed as latitude andlongitude) from other geographic data, suchas street addresses, or zip codes (postal codes)Reverse Geocoding performs the oppositeoperation
  • 72. Geocoding (cont’d) Address Geocoding CoordinatesCoordinates Reverse Geocoding Address
  • 73. Geocoder ClassA class for handling Geocoding and ReverseGeocodingUseful methods: getFromLocation(double latitude, double longitude, int maxResults) getFromLocationName(String locationName, int maxResults, double lowerLeftLatitude, double lowerLeftLongitude, double upperRightLatitude, double upperRightLongitude) getFromLocationName(String locationName, int maxResults)
  • 74. SensorsAndroid supports many different types ofsensor devices: TYPE_ACCELEROMETER: Measures acceleration in the x-, y-, and z axes TYPE_LIGHT: Tells you how bright your surrounding area is TYPE_MAGNETIC_FIELD: Returns magnetic attraction in the x-, y-, and z-axes TYPE_ORIENTATION: Measures the yaw, pitch, and roll of the device TYPE_PRESSURE: Senses the current atmospheric pressure TYPE_PROXIMITY: Provides the distance between the sensor and some object TYPE_TEMPERATURE: Measures the temperature of the surrounding area
  • 75. Sensor ManagerAllows utilizing the devices sensorsAn instance of this class is retrieved bycalling Context.getSystemService(Context.SENSOR_SERVICE)Specific sensors are retrieved usinggetDefaultSensor(Sensor.TYPE_ACCELEROMETER)
  • 76. SensorEventListenerReceives notifications from theSensorManager when sensor values areupdatedCallback Methods: onAccuracyChanged(Sensor sensor, int accuracy) onSensorChanged(SensorEvent event)
  • 77. TELEPHONY, MESSAGING ANDNOTIFICATIONS
  • 78. Telephony ManagerProvides access to information about thetelephony services on the deviceRequires READ_PHONE_STATE permissionGet an instance of this class by callingContext.getSystemService(Context.TELEPHONY_SERVICE)
  • 79. Telephony Manager(cont’d)Useful Methods: getDeviceId() String getLine1Number() String getNetworkOperatorName() int getNetworkType() int getPhoneType() String getSimSerialNumber() String getSubscriberId() isNetworkRoaming() void listen(PhoneStateListener listener, int events)
  • 80. SMS Messages SupportAndroid API supports developing applicationsthat can send and receive SMS messagesSmsManager Manages SMS operations suchas sending data, text, and PDU SMS messages
  • 81. NotificationsA Notification is a persistentmessage that not only showsup in the status bar but staysin a notification area until theuser deletes itManaged by Notification andNotificationManager Classes
  • 82. I18N AND LOCALIZATION
  • 83. LocalizationAll resources in Android can be configured to supportlocalizationExample: Default (English): res/values/strings.xml Arabic: res/values-ar/strings.xml French: res/values-fr/strings.xmlUse Android context to change locale Locale locale = context.getResources().getConfiguration().locale
  • 84. DEVELOPING AN ANDROID APP
  • 85. SDKContains Dalvik VM, Java libraries andEmulator
  • 86. IDEAn Android plugin, called AndroidDevelopment Tools (ADT) (https://dl-ssl.google.com/android/eclipse/), is availablefor Eclipse IDEMotoDev is an Eclipse based IDE withtremendous features for AndroidDevelopment
  • 87. Create an AVD
  • 88. Create new project
  • 89. Development Checklist
  • 90. When to use NDK?Typical good candidates for the NDK are self-contained, CPU-intensive operations thatdont allocate much memorySuch operations include signal processing,physics simulation, real time imageprocessing, etc.
  • 91. Debugging
  • 92. Package and deploySign application using Eclipse Export WizardChoose a strong password to sign yourapplicationApplication is exported to an APK file
  • 93. Publish to marketPublishing checklist:1. Test your application extensively on an actual device2. Consider adding an End User License Agreement in your application3. Consider adding licensing support4. Specify an icon and label in the applications manifest5. Turn off logging and debugging and clean up data/files
  • 94. Publish to market (cont’d)6. Version your application7. Obtain a suitable cryptographic key8. Register for a Maps API Key, if your application is using MapView elements9. Sign your application10. Obfuscate your code using ProGuardFollow MotoDev publishing steps
  • 95. Support and ResourcesAndroid Developers(http://developer.android.com/index.html)Offers SDK downloads, Reference (JAVADOCs),Resources and Dev Guide
  • 96. ANDROID MARKET
  • 97. OverviewAndroid’s application repositorySimilar to Apple’s App Store and Nokia’s OviStoreBy August 2010, there were over 80,000applications available for download, with over1 billion application downloads
  • 98. Overview (cont’d)
  • 99. Overview (cont’d)
  • 100. Publishing on Android Market1. Create a developer profile using a Google account2. Pay a registration fee of 25$3. For paid applications, Google receives a 30% transaction fee4. Google handles version updates
  • 101. Android Market support in EgyptTo create a Developer profile, a Google Checkoutaccount in requiredGoogle Checkout is not supported in Egypt!A valid credit card in a supported country is one workaroundUsing GetJar to expose applications is anothersolution
  • 102. ANDROID APPLICATION TRENDS
  • 103. What are analysts saying?“Android Is Destroying Everyone, EspeciallyRIM -- iPhone Dead In Water” - BusinessInsider“Android market share to near 50 percent” -Gartner“Androids Market Share Soars Ahead OfApple iPhones” - The Huffington Post
  • 104. Market Share Data collected on Q4 2010
  • 105. Market Share (cont’d)
  • 106. Usage Share Data collected on May 2011
  • 107. Available Applications
  • 108. Paid vs. Free
  • 109. Category Analysis
  • 110. Category Analysis (cont’d)
  • 111. Key factors for 2010Entertainment category will remain mostpopularFree applications will continue to dominateThe rise of books and reference categories
  • 112. Future of Android AppsLocalized contentMore mature business applicationsApplications for Tablet devicesApplications utilizing location and mapsSocial Network aggregatorsSatallite Systems (SSTL)Software Development process for mobileapplications
  • 113. Gartner Top 10 Mobile Applications for 2012 Mobile Money Transfer Location-Based Services Mobile Search Mobile Browsing Mobile Health Monitoring Mobile Payment Near Field Communication Services Mobile Advertising Mobile Instant Messaging Mobile Music
  • 114. Thank you