Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Understanding Android Application Development

Understanding Android Application Development

Rakeeb helped participants get basic understanding of Android Studio, Gradle build system, Android's fundamental application components, basic Android development patterns, common operations performed by an Android application, various tools, platforms and libraries assisting towards a smooth development process and various sources of inspiration and knowledge for Android. Ncell App Camp 2015.

Ncell App Camp

November 08, 2015
Tweet

More Decks by Ncell App Camp

Other Decks in Technology

Transcript

  1. Table of Contents ➔ Planning the development process ➔ Getting

    to know your APIs and tools ➔ Implementing Material Design ➔ Supporting multiple devices ➔ Common operations performed by applications ➔ Understanding the Android gradle plugin ➔ Recommendations
  2. Table of Contents ➔ Planning the development process ➔ Getting

    to know your APIs and tools ➔ Implementing Material Design ➔ Supporting multiple devices ➔ Common operations performed by applications ➔ Understanding the Android gradle plugin ➔ Recommendations
  3. Planning the development process 1. Identify your problem statement a.

    What problem is your application trying to address 2. Understand your target users a. Who are your users, their goals and requirements 3. Understand a minimally viable solution set a. Plan to release a basic functional application ASAP b. Plan for incremental updates taking advantage of efficient upgrade paths offered via regular updates 4. Build prototypes and mock-ups for your application a. Gives you a sense of direction and feel for the application before development
  4. Planning the development process (Contd.) 5. Establish a user testing

    focus group a. Get insights on what the users are looking for b. Use closed beta testing using Google Groups or Google+ communities c. Great platform to get user feedback and feature requests and catch bugs d. Make changes to application accordingly 6. Plan for multiple releases a. New features re-engage users b. 2-3 months interval for major releases is recommended
  5. Planning the development process (Contd.) 7. Know what’s out there

    a. Skim through competitors as well as various alternatives b. Take inspiration from them 8. Decide on technology you can live (and grow) with a. Includes libraries, analytics tools and cloud platforms powering your application 9. Plan to analyze a. Define milestones and ways to measure success b. Review your process
  6. Planning the development process (Contd.) ➔ Further readings: ◆ 10

    Things to Plan for When Developing a Mobile App ◆ Alpha/Beta testing for users ◆ Google Analytics ◆ Google Cloud Platform ◆ Fabric ◆ Firebase ◆ Martin's series on creating your own Android app blog
  7. Table of Contents ➔ Planning the development process ➔ Getting

    to know your APIs and tools ➔ Implementing Material Design ➔ Supporting multiple devices ➔ Common operations performed by applications ➔ 3rd party libraries ➔ Understanding the Android gradle plugin
  8. Getting to know your APIs ➔ Best source of knowledge:

    ◆ Android developers section ➔ Recommended navigation path: ◆ API Guides ◆ Training ◆ API References
  9. Getting to know your APIs (Contd.) ➔ Browse through samples,

    open source projects and other applications
  10. Getting to know your APIs (Contd.) ➔ Browse through samples,

    open source projects and other applications
  11. Getting to know your tools ➔ Best source of knowledge:

    ◆ Android tools section ◆ Android tools project site ◆ Android Support Library ◆ Data Binding Library
  12. Table of Contents ➔ Planning the development process ➔ Getting

    to know your APIs and tools ➔ Implementing Material Design ➔ Supporting multiple devices ➔ Common operations performed by applications ➔ Understanding the Android gradle plugin ➔ Recommendations
  13. Implementing Material Design ➔ Step 1: Include the support appcompat

    and design library in your project dependencies compile "com.android.support: appcompat-v7:23.1.0" compile "com.android.support: design:23.1.0" ➔ Step 2: Define the theme for your application <style name="AppTheme" parent=" Theme.AppCompat.Light" /> To use toolbars be sure to disable the action bar and window title <item name="windowActionBar">false</item> <item name=" windowNoTitle">true</item>
  14. Implementing Material Design (Contd.) ➔ Step 3: Extend the AppCompatActivity

    ➔ Step 4: Survey through various UI elements to be initialized
  15. Material Design Elements (Contd.) 8. Material Icons a. Import the

    design icons from Android Studio as Vector Assets
  16. Material Design Elements (Contd.) 8. Material Icons b. Material icons

    are available for download c. Use the Android Iconics library for access to tons of design icons
  17. Implementing Material Design (Contd.) ➔ Be sure to check out

    the Material Design Guidelines ➔ Make sure your application adheres to Metrics and Keyline through Keyline Pushing
  18. Table of Contents ➔ Planning the development process ➔ Getting

    to know your APIs and tools ➔ Implementing Material Design ➔ Supporting multiple devices ➔ Common operations performed by applications ➔ Understanding the Android gradle plugin ➔ Recommendations
  19. Supporting multiple devices 1. Screen size a. Actual physical size,

    measured as the screen's diagonal 2. Screen density a. The quantity of pixels within a physical area of the screen; usually referred to as dpi (dots per inch)
  20. Supporting multiple devices (Contd.) ➔ Four generalized sizes ◆ small,

    normal, large, and xlarge ➔ Set of six generalized densities ◆ ldpi (low) ~120dpi ◆ mdpi (medium) ~160dpi ◆ hdpi (high) ~240dpi ◆ xhdpi (extra-high) ~320dpi ◆ xxhdpi (extra-extra-high) ~480dpi ◆ xxxhdpi (extra-extra-extra-high) ~640dpi ➔ Formula: px = dp * (dpi / 160)
  21. Supporting multiple devices (Contd.) 3. Configuring resource qualifiers a. <resources_name>-<config_qualifier>

    i. <resources_name> is the directory name of the corresponding default resources. ii. <qualifier> is a name that specifies an individual configuration for which these resources are to be used. iii. You can append more than one <qualifier>. Separate each one with a dash.
  22. Supporting multiple devices (Contd.) ➔ Further readings: ◆ Official documentation

    ◆ Android UI tutorial ◆ Understanding pixel density ◆ New tools for managing screen sizes ◆ Supporting different screen sizes ◆ Providing Resources
  23. Table of Contents ➔ Planning the development process ➔ Getting

    to know your APIs and tools ➔ Implementing Material Design ➔ Supporting multiple devices ➔ Common operations performed by applications ➔ Understanding the Android gradle plugin ➔ Recommendations
  24. Network operations ➔ Common operations: ◆ Defining a HTTP client

    ◆ Checking if network is available ◆ Performing network operations on a separate thread ◆ Connection and data download ◆ Converting InputStream to String ➔ PRO-TIP Always fetch JSON data wherever possible, it’s relatively easier working with them, as opposed to working with XML responses.
  25. Network operations (Contd.) ➔ PRO-TIP Serialize JSON to Java Objects.

    ◆ Using ‘gson’ • Provides simple toJson() and fromJson() methods to convert Java objects to JSON and vice-versa ◆ Generate POJO’s via jsonschem2pojo ➔ PRO-TIP Use ‘OkHttp’ as your default HTTP client and use ‘Retrofit’ to make api requests
  26. ListView RecyclerView ➔ Rigid API ➔ Provides a lot of

    functionality out of the box ◆ setEmptyView() ◆ addHeaderView() ◆ addFooterView() ➔ Flexible API ➔ Separation of concerns ➔ Plug and play ◆ Add ItemDecoration ◆ Add LayoutManager ◆ Add ItemAnimator
  27. Listing items (Contd.) ➔ PRO-TIP Data bind all things! ◆

    Removes boilerplate code for view and view data initialization ◆ Allows custom attribute definition for views
  28. Saving Data ➔ Working with data presents us with the

    following options: ◆ Using Preferences • SharedPreferences allows us to store primitive data in ‘key-value’ pairs ◆ Using Storage • Either use cache or directly store files ◆ Using Database ➔ PRO-TIP Use libraries like DiskLruCache, Picasso, GreenDAO, Tray, Realm, etc. to make development process easier. ➔ PRO-TIP Use ORM’s or POJO’s when working with Cursors.
  29. Debugging ➔ adb ◆ middleman between a device and your

    development system ➔ DDMS ◆ DDMS is a graphical program that communicates with your devices through adb ◆ DDMS can be used to: • Capture screenshots • Spoof incoming calls and messages • Mock locations • Memory profiling
  30. Debugging (Contd.) ➔ Use ‘Log’ to send log outputs ◆

    Common logging methods include: • v(String, String) (verbose) • d(String, String) (debug) • i(String, String) (information) • w(String, String) (warning) • e(String, String) (error) ➔ PRO-TIP Use Timber and Stetho to make your application development friendly.
  31. Table of Contents ➔ Planning the development process ➔ Getting

    to know your APIs and tools ➔ Implementing Material Design ➔ Supporting multiple devices ➔ Common operations performed by applications ➔ Understanding the Android gradle plugin ➔ Recommendations
  32. Build Tools “Build tools are series of executable & ordered

    tasks that lead to source code compilation and assemblance of a deliverable” ➔ General anatomy of a build tool comprises of: ◆ Build files ◆ Build inputs & outputs ◆ Build engines ◆ Dependency manager
  33. ➔ Gradle is a build tool ➔ Gradle takes inspiration

    from Ant, Maven, Ivy and uses Groovy as a DSL ➔ Gradle is based on plugins ◆ Plugins define tasks
  34. android { compileSdkVersion 23 buildToolsVersion "23.0.1" defaultConfig { applicationId "com.appcampdemo"

    minSdkVersion 15 targetSdkVersion 23 versionCode 1 versionName "1.0" } ... }
  35. android { compileSdkVersion 23 buildToolsVersion "23.0.1" defaultConfig { applicationId "com.appcampdemo"

    minSdkVersion 15 targetSdkVersion 23 versionCode 1 versionName "1.0" } ... }
  36. AppExtension: ProductFlavor (defaultConfig) ➔ defaultConfig is a ‘ProductFlavor’ ➔ What

    are Product Flavors ? ◆ “A product flavor defines a customized version of the application build by the project. A single project can have different flavors which change the generated application.” ➔ Default configuration shared by all product flavors ➔ Contains basic properties such as applicationId, versionName, etc. ➔ Mainly consists of variables that were previously assigned in ‘AndroidManifest.xml’
  37. AppExtension: ProductFlavor (defaultConfig) ➔ PRO-TIP BuildConfig class is generated for

    each product flavor, use it if(BuildConfig.DEBUG) { ... } StringBuilder requestBody = new StringBuilder(); requestBody.append(BuildConfig.baseUrl);
  38. AppExtension: ProductFlavor (defaultConfig) ➔ PRO-TIP Use ‘buildConfigField’ or ‘resValue’ to

    define variables specific to your flavor defaultConfig { … buildConfigField('String', 'baseUrl', "...") resValue(‘string’, ‘appName’, “...”) }
  39. AppExtension: BuildTypes ➔ A build type allows configuration of how

    an application is packaged for debugging or release purpose. buildTypes { release { minifyEnabled false ... } debug { applicationIdSuffix ".debug" ... } }
  40. AppExtension: ProductFlavor ➔ Provides a great way to separate builds

    for your app productFlavor { free { buildConfigField ‘int’, ‘SIGNING_KEY’, ‘xxx’ ... } paid { buildConfigField ‘int’, ‘SIGNING_KEY’, ‘yyy’ ... } }
  41. AppExtension: BuildTypes & ProductFlavor ➔ PRO-TIP Structure your project to

    accommodate changes for debug and different flavor builds
  42. Table of Contents ➔ Planning the development process ➔ Getting

    to know your APIs and tools ➔ Implementing Material Design ➔ Supporting multiple devices ➔ Common operations performed by applications ➔ Understanding the Android gradle plugin ➔ Recommendations
  43. Recommendations ➔ GAS© your problems ◆ G >> Google your

    problems ◆ A >> Ask for help (stack overflow, groups, forums, etc.) ◆ S >> Search for alternatives
  44. ➔ Communities to join: ◆ Android Development ◆ Android projects

    on Github ◆ Android performance patterns ◆ Android Studio
  45. ➔ People to follow: ◆ Chet Haase ◆ Chris Banes

    ◆ Colt McAnlis ◆ Ian Lake ◆ Roman Nurik, and other people from the Android team add google developer experts and don’t forget to follow me :)
  46. ➔ Podcasts ◆ Android Developers Backstage ◆ Designer Notes ◆

    Fragmented Podcast ◆ The Blerg ◆ The Java Posse
  47. ➔ Channels to follow ◆ Android Developers ◆ Android Dialogs

    ◆ Google Developers ◆ NewCircle Training ◆ Search for “droidcon” on Youtube