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

Introduction to Android Development

Introduction to Android Development

Bcf368379f7010d91cd12d2ffa3427f8?s=128

Omolara Adejuwon

December 13, 2014
Tweet

Transcript

  1. INTRODUCTION TO ANDROID DEVELOPMENT Adejuwon Omolara Twitter: @_larikraun

  2. Overview • Android is a software stack for mobile devices

    that includes an operating system, middleware and key applications. • Android OS is divided into five sections • Applications: This is where applications to be installed are written. E.g. Games, Browser etc. • Application Framework: This layer provides many higher-level services to applications in the form of Java classes. • Android Runtime: This section provides a key component called Dalvik Virtual Machine. Dalvik VM enables every android application to run in its own process, with its own instance of the Dalvik VM. Dalvik VM is optimised to run on slow CPU, low RAM, low power devices. It runs .dex files and not .class nor .jar • Libraries: e.g. SQLite database, repository for storage and sharing of application. • Linux Kernel : it provides basic system functionality e.g. process management, device management etc.
  3. Platform Overview

  4. Android has evolved over the years : • Android 1.1

    *Not relevant in the ecosystem* • Android 1.5 Cupcake *Not relevant in the ecosystem* • Android 1.6 Donut *Not relevant in the ecosystem* • Android 2.0/2.1 Eclair *Not relevant in the ecosystem* • Android 2.2.x Froyo *Not too relevant in the ecosystem* • Android 2.3.x Gingerbread *Still somewhat relevant in the ecosystem* • Android 3. x Honeycomb *Not relevant in the ecosystem* • Android 4.0.x Ice Cream Sandwich *Still quite relevant in the ecosystem*
  5. And now we have Lollipop…

  6. Tools you need to get started… • A fair knowledge

    of Java • Latest Java Development Kit (JDK) : Android Apps are developed using Java. http://www.oracle.com/technetwork/java/javase/downloads/inde x.html • Eclipse Integrated Development Environment (IDE) https://www.eclipse.org/downloads/ or any other suitable IDE. • Android SDK http://developer.android.com • ADT Tools for Eclipse (via Internet)
  7. Application Components Applications use four main components: • Activity •

    Service • Broadcast Receivers • Content Providers
  8. Activity Activities: A single screen that is visible to user.

    They dictate the UI and handle the user interaction to the smartphone screen. public class MainActivity extends Activity { }
  9. Activity Lifecycle

  10. Services Services: They handle background processes associated with an application.

    They can be used to update an application when it’s not active. public class MyService extends Service { }
  11. Service Lifecycle

  12. Broadcast Receiver Broadcast Receivers: They handle communication between Android OS

    and applications. They listen for android system events. public class MyReceiver extends BroadcastReceiver { }
  13. Content Providers Content Providers: They handle and manage data, usually

    stored in database and data access for queries. public class MyContentProvider extends ContentProvider { }
  14. More Components… • Fragments: Represents a behaviour or a portion

    of user interface. • Views: UI elements that are drawn onscreen. They are responsible for event handling e.g. ContextMenu, Menu etc. • Widgets: They are more advanced UI elements e.g Button, CheckBox, ImageView etc. • Layouts: View hierarchies that control screen format and appearance of the views.
  15. • Intents: Messages wiring components together. An intent is composed

    of an action it needs to perform. They are used to start activities and to communicate among various parts of the android system. • Resources: External elements such as strings, drawables and constants • Manifest: Configuration file for the application.
  16. Layout Manager It is responsible for the layout of itself

    and its child Views. Android supports different default layout managers. To get a desired layout, there are some few terms you would come across. ✔ android:layout_width defines the width of the widget. ✔ android:layout_heigth defines the height of the widget. ✔ match_parent tells the application to maximize the widget in its parent. ✔ wrap_content tells the layout to allocate the minimum amount so that the widget is rendered correctly.
  17. Image source: vogella

  18. Who doesn’t like easy tasks? Well, I do… Google exposes

    a number of functionalities in android. To create spectacular apps, you should make use of them. • Touchscreen • GPS • Accelerometer • Internet • Audio and Video support • Contacts • Security • Google APIs
  19. API levels This is an integer value that uniquely identifies

    the framework API revision offered by a version of the android platform. ✔ It lets the android platform describe the maximum framework API revision that it supports. ✔ It lets applications describe the framework API revision that they require. ✔ It lets the system negotiate the installation of applications on the user’s device such that version-incompatible are not installed. You can catch more gist on API levels here
  20. None
  21. Image source: Android’s site

  22. My One-Dollar To write a working android application, you need

    to consider keeping it simple. Nobody likes a complex-for-nothing application. I encourage drawing mock-ups ( a visual representation of how you want the application to look like), flow charts ( a step-by-step approach to achieving your goal) as one of the first steps before jumping on your IDE. You will need to step up your UI/UX game to ‘wow’ your users.
  23. I think these will help too • Make Google your

    friend • Get familiar with android developers’ site • Read documentations before using any API • Join forums that will help. One of the most popular is stackoverflow • Get close to the ‘gurus’- they have a lot to offer. • Read books that will help.
  24. My ‘Hello World’ Application This is a dummy application that

    just displays ‘Hello World, MyFirstApp’ ✔ MyFirstApp.java + main.xml =
  25. MyFirstApp.java

  26. The main.xml file

  27. AndroidManifest.xml

  28. ✔ package attribute defines the base package for the Java

    objects referred to in a particular file. ✔ android:versionCode must be an integer. You typically start from ‘1’ and increase the value by one if you roll-out a new version of your application. ✔ android:versionName is what the users see. It can be any string. ✔ android:minSdkVersion defines the minimum version of android your applicaton works on. A user cannot install your application on a device with a lower API level than specified in this attribute. ✔ android:targetSdkVersion specifies the version on which you tested and developed. It is a good practice to always set this to the latest Android API version.
  29. ✔ <application> section is a container for declaring android components.

    ✔ <activity> tag defines an activity component. ✔ android:name="android.intent.action.MAIN" can be started and the category ✔ android:name="android.intent.category.LAUNCHER“ parameter tells the Android system to add the activity to the launcher.
  30. Questions???