Workshop Android for Java Developers

35
Android Development for Java Developers Michael Hantler FullStack Developers Israel April 24 th 2014 Hosted by:

description

The presentation from the workshop "Android for Java Developers" given on April 24th 2014

Transcript of Workshop Android for Java Developers

Page 1: Workshop Android for Java Developers

Android Development for Java Developers

Michael Hantler

FullStack Developers Israel

April 24th 2014

Hosted by:

Page 2: Workshop Android for Java Developers

WHO AM I?

Working as a consultant in Android Development @ Tikal Knowledge.Extensive work in mobile HTML5-hybrid applicationsWorked for leading mobile security companies on Android/Mobile applications.

Contact: [email protected]

Page 3: Workshop Android for Java Developers

Michael Hantler, Lead Android

Architect

over 2 years of

Android Specific Development

Page 4: Workshop Android for Java Developers

WHO WE ARE?

Page 5: Workshop Android for Java Developers

We help companies build,deliver, deploy, manage

and optimize their products.

Page 6: Workshop Android for Java Developers

OUR EXPERTESE

Page 7: Workshop Android for Java Developers

Android Development for Java Developers

text

Page 8: Workshop Android for Java Developers

Prerequisite Knowledge

• Java Development (basic understanding of dev environments and UI component implementations)

Prerequisite Installs

• Eclipse• ADT plugin for Eclipse• Android SDK with at least version 4.3

Page 9: Workshop Android for Java Developers

Outline

Android at a GlanceUI Design via XMLActivities and FragmentsViews

Dialogs and ToastsBackwards Compatibility

Lists and Adapters

Page 10: Workshop Android for Java Developers

Android at a GlanceShort History of Android

Page 11: Workshop Android for Java Developers

Android at a GlanceAndroid Software Stacks

Page 12: Workshop Android for Java Developers

Android at a GlanceDevelopment Tools

Page 13: Workshop Android for Java Developers

Android at a GlanceGoogle’s Development References and

ToolsPackage ReferencesDevelopment Tools

Building Your First AppDeveloper Blog

Sample Apps (download through SDK manager)

Page 14: Workshop Android for Java Developers

Android at a GlanceHello World example

(also covering Project structure/creation/debuging/DDMS/Manifest)

Page 15: Workshop Android for Java Developers

Android UI via XML

Utilization

• UI can be designed for one or many screens using XML parameters and graphical previews using Android Developer Toolkit WYSIWYG editor.

• XMLs are then loaded dynamically in Java components and can be accessed/manipulated on the Java level.

Usefulness• Offers similar development to HTML and JavaScript

paradigm• Easily generate UI assets in WYSIWYG • Naming conventions allow to design XML for specific

screen sizes, orientations, Android SDK versions, languages

text

Page 16: Workshop Android for Java Developers

R.javatext

Page 17: Workshop Android for Java Developers

Android UI via XMLXML layout example (from Hello

World)

Page 18: Workshop Android for Java Developers

Activities and Fragments

Activities• An “application component that provides a screen with

which users can interact in order to do something, such as dial the phone, take a photo, send an email, or view a map.” - Activities

• Usually tied to an xml layout that constitutes its ContentView

Fragments• Only added in Android 3.0.xx in order to deal with tablets,

but now available with backwards compatibility using Support Library

• Different concept from Activities, now need to think about aspects of each screen and not just the screen themselves in order to offer responsive design for multiple screens

text

Page 19: Workshop Android for Java Developers

Activity Lifecycle

Page 20: Workshop Android for Java Developers

Fragment Lifecycle

Page 21: Workshop Android for Java Developers

Intents

Description

• “An intent is an abstract description of an operation to be performed.” – Intent Reference

• Intents offer a runtime binding between Activities and Applications allowing them to be added to the different process stacks.

Example (Explicit Intent, activities need to be added to manifest)

Intent intent = new Intent(this, DisplayMessageActivity.class);intent.putExtra(EXTRA_ACTION, “warning”);this.startActivity(intent);

text

Page 22: Workshop Android for Java Developers

Code sample after next topic

Page 23: Workshop Android for Java Developers

Views“This class represents the basic building block for user interface components. A View occupies a rectangular area on the screen and is responsible for drawing and event handling. View is the base class for widgets, which are used to create interactive UI components (buttons, text fields, etc.). The ViewGroup subclass is the base class for layouts, which are invisible containers that hold other Views (or other ViewGroups) and define their layout properties.”

text

Page 24: Workshop Android for Java Developers

Commonly Used Views

Definitions from developer.android.com• TextView - Displays text to the user and optionally allows

them to edit it. A TextView is a complete text editor, however the basic class is configured to not allow editing…

• EditText - EditText is a thin veneer over TextView that configures itself to be editable.

• Button - Represents a push-button widget. Push-buttons can be pressed, or clicked, by the user to perform an action.

• ImageView - Displays an arbitrary image, such as an icon. The ImageView class can load images from various sources (such as resources or content providers), takes care of computing its measurement from the image so that it can be used in any layout manager, and provides various display options such as scaling and tinting.

text

Page 25: Workshop Android for Java Developers

Commonly Used Views (continued)

Definitions from developer.android.com• ProgressBar - Visual indicator of progress in some

operation…• CheckBox - A checkbox is a specific type of two-states

button that can be either checked or unchecked. • RadioButton - A radio button is a two-states button that

can be either checked or unchecked…contrary to a CheckBox, a radio button cannot be unchecked by the user once checked.

• WebView - A View that displays web pages. This class is the basis upon which you can roll your own web browser or simply display some online content within your Activity. It uses the WebKit rendering engine to display web pages and includes methods to navigate forward and backward through a history, zoom in and out, perform text searches and more.

text

Page 26: Workshop Android for Java Developers

Email Fragment/Activity Example (with two buttons

instead of list)

Page 27: Workshop Android for Java Developers

ListViews and Adapters

ListView is a view group that displays a list of scrollable items. The list items are automatically inserted to the list using an Adapter that pulls content from a source such as an array or database query and converts each item result into a view that's placed into the list.

text

Page 28: Workshop Android for Java Developers

Email Fragment/Activity Example (with list)

Page 29: Workshop Android for Java Developers

Dialogs

A dialog is a small window that prompts the user to make a decision or enter additional information. A dialog does not fill the screen and is normally used for modal events that require users to take an action before they can proceed.

text

Page 30: Workshop Android for Java Developers

ToastsA toast provides simple feedback about an operation in a small popup. It only fills the amount of space required for the message and the current activity remains visible and interactive. For example, navigating away from an email before you send it triggers a "Draft saved" toast to let you know that you can continue editing later. Toasts automatically disappear after a timeout.

text

Page 31: Workshop Android for Java Developers

Email Fragment/Activity Example (with popups)

Page 32: Workshop Android for Java Developers

Support Library

The Android Support Library package is a set of code libraries that provide backward-compatible versions of Android framework APIs as well as features that are only available through the library APIs.

text

Including features like:• Fragments• ViewPager• DrawerLayout• ActionBar• Many more

Page 33: Workshop Android for Java Developers

Email Fragment/Activity Example (add Support Library

and ActionBar)

Page 34: Workshop Android for Java Developers

Google Play Services and Google Play Game Services

Google Play services gives you the freedom to use the newest APIs for popular Google services without worrying about device support. Updates to Google Play services are distributed automatically by the Google Play Store and new versions of the client library are delivered through the Android SDK Manager. This makes it easy for you to focus on what's important: your users' experience.

Include Services like:• Geofencing• Google Wallet• Game Leader Boards• Cloud Data• Much Much More

text

Page 35: Workshop Android for Java Developers

THANK YOU

Michael HantlerEmail: [email protected]