Slide 1

Slide 1 text

INTRODUCTION TO ANDROID DEVELOPMENT Adejuwon Omolara Twitter: @_larikraun

Slide 2

Slide 2 text

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.

Slide 3

Slide 3 text

Platform Overview

Slide 4

Slide 4 text

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*

Slide 5

Slide 5 text

And now we have Lollipop…

Slide 6

Slide 6 text

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)

Slide 7

Slide 7 text

Application Components Applications use four main components: • Activity • Service • Broadcast Receivers • Content Providers

Slide 8

Slide 8 text

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 { }

Slide 9

Slide 9 text

Activity Lifecycle

Slide 10

Slide 10 text

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 { }

Slide 11

Slide 11 text

Service Lifecycle

Slide 12

Slide 12 text

Broadcast Receiver Broadcast Receivers: They handle communication between Android OS and applications. They listen for android system events. public class MyReceiver extends BroadcastReceiver { }

Slide 13

Slide 13 text

Content Providers Content Providers: They handle and manage data, usually stored in database and data access for queries. public class MyContentProvider extends ContentProvider { }

Slide 14

Slide 14 text

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.

Slide 15

Slide 15 text

• 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.

Slide 16

Slide 16 text

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.

Slide 17

Slide 17 text

Image source: vogella

Slide 18

Slide 18 text

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

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

Image source: Android’s site

Slide 22

Slide 22 text

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.

Slide 23

Slide 23 text

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.

Slide 24

Slide 24 text

My ‘Hello World’ Application This is a dummy application that just displays ‘Hello World, MyFirstApp’ ✔ MyFirstApp.java + main.xml =

Slide 25

Slide 25 text

MyFirstApp.java

Slide 26

Slide 26 text

The main.xml file

Slide 27

Slide 27 text

AndroidManifest.xml

Slide 28

Slide 28 text

✔ 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.

Slide 29

Slide 29 text

✔ section is a container for declaring android components. ✔ 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.

Slide 30

Slide 30 text

Questions???