DevFest Sul 2014 - Android 4 lazy iOS Devs

60
Give yourself to the Dark Side! Jackson F. de A. Mafra

description

A little introduction to a new world of awesomeness. Some clues to ios developers start correctly in Android dev passion.

Transcript of DevFest Sul 2014 - Android 4 lazy iOS Devs

Page 1: DevFest Sul 2014 - Android 4 lazy iOS Devs

Give yourself to the Dark Side!

Jackson F. de A. Mafra

Page 2: DevFest Sul 2014 - Android 4 lazy iOS Devs

http://developer.android.com/design/index.html

follow this, seriously!

Page 3: DevFest Sul 2014 - Android 4 lazy iOS Devs

Understand some of the key UI paradigms in use on Android today: the action bar, the overflow menu, the back button, the share action,

and more.

Page 4: DevFest Sul 2014 - Android 4 lazy iOS Devs

No More Menu Button

Page 5: DevFest Sul 2014 - Android 4 lazy iOS Devs

New Buttons

Page 6: DevFest Sul 2014 - Android 4 lazy iOS Devs

Notifications

Page 7: DevFest Sul 2014 - Android 4 lazy iOS Devs

Navigation

Page 8: DevFest Sul 2014 - Android 4 lazy iOS Devs

ActionBar

Page 9: DevFest Sul 2014 - Android 4 lazy iOS Devs

ActionBar

Page 10: DevFest Sul 2014 - Android 4 lazy iOS Devs

MultiPane

Page 11: DevFest Sul 2014 - Android 4 lazy iOS Devs

Dialogs

Page 12: DevFest Sul 2014 - Android 4 lazy iOS Devs

Android is not iOS

Page 13: DevFest Sul 2014 - Android 4 lazy iOS Devs

Android is not iOS

Page 14: DevFest Sul 2014 - Android 4 lazy iOS Devs

IDE

Android Studio

or

(Eclipse ADT plugin)

Page 15: DevFest Sul 2014 - Android 4 lazy iOS Devs

Android SDK and AVD Manager

Page 16: DevFest Sul 2014 - Android 4 lazy iOS Devs

Language Application Structure

There are many differences between Objective-C and Java

Page 17: DevFest Sul 2014 - Android 4 lazy iOS Devs

Java

Say what you will about Java, in the end it's just another language. Be thankful there is no J2EE

in sight.

Page 18: DevFest Sul 2014 - Android 4 lazy iOS Devs

Language Application Structure

Referencing this.object will not call your custom getter. You must use this.getObject.

Page 19: DevFest Sul 2014 - Android 4 lazy iOS Devs

Language Application Structure

Java methods are typically written as actions or queries, such as getCell(), instead of

cellForRowAtIndexPath:.

Page 20: DevFest Sul 2014 - Android 4 lazy iOS Devs

Simulator

I used to think the iOS simulator was painful, now I realise it's pretty awesome.

Skip the Android simulator all together and deploy to a real device, or be prepared to spend

a lot of time waiting.

Consider to use Genymotion, a fastest Android emulator for app testing and presentation.

Page 21: DevFest Sul 2014 - Android 4 lazy iOS Devs

Project Structure

Android applications are primarily broken into two sections, the first of which is the Java

source code.

Page 22: DevFest Sul 2014 - Android 4 lazy iOS Devs

Project Structure

The source code is structured via the Java package hierarchy, and it can be structured as you please. However, a common practice is to

use top-level categories for activities, fragments, views, adapters, and data (models

and managers).

Page 23: DevFest Sul 2014 - Android 4 lazy iOS Devs

Project Structure

The second major section is the res folder, short for ‘resource’ folder.

Page 24: DevFest Sul 2014 - Android 4 lazy iOS Devs

Project Structure

The res folder is a collection of images, XML layout files, and XML value files that make up

the bulk of the non-code assets.

Page 25: DevFest Sul 2014 - Android 4 lazy iOS Devs

Project Structure

Android uses Layouts which are xml. They are completely independent from each other.

Android Studio also has a nice WYSIWYG editor

Page 26: DevFest Sul 2014 - Android 4 lazy iOS Devs

Project Structure

On iOS, images are either @2x or not, but on Android there are a number of screen density

folders to consider.

Page 27: DevFest Sul 2014 - Android 4 lazy iOS Devs

Project Structure

Android uses folders to arrange images, strings, and other values for screen density.

Page 28: DevFest Sul 2014 - Android 4 lazy iOS Devs

Project Structure

One last correlation in project structure is the AndroidManifest.xml file.

Page 29: DevFest Sul 2014 - Android 4 lazy iOS Devs

Project Structure

This file is the equivalent of the Project-Info.plist file on iOS, and it stores information for

activities, application names, and set Intents (system-level events) that the application can

handle.

Page 30: DevFest Sul 2014 - Android 4 lazy iOS Devs

Activities

Activities are the basic visual unit of an Android app, just as UIViewControllers are

the basic visual component on iOS.

Page 31: DevFest Sul 2014 - Android 4 lazy iOS Devs

Activities

Instead of a UINavigationController, the Android OS keeps an activity stack that it

manages.

Page 32: DevFest Sul 2014 - Android 4 lazy iOS Devs

Activities

In essence, the activity lifecycle is very similar to the UIViewController lifecycle.

Page 33: DevFest Sul 2014 - Android 4 lazy iOS Devs

Activities

Page 34: DevFest Sul 2014 - Android 4 lazy iOS Devs

Fragments

The Fragment concept is unique to Android and came around somewhat recently in

Android 3.0 (2010).

Page 35: DevFest Sul 2014 - Android 4 lazy iOS Devs

Fragments

Fragments are mini controllers that can be instantiated to fill activities.

Page 36: DevFest Sul 2014 - Android 4 lazy iOS Devs

Fragments

Also note that fragments do not have their own contexts and they rely heavily on activities for

their connection to the application’s state.

Page 37: DevFest Sul 2014 - Android 4 lazy iOS Devs

Fragments

Tablets are a great fragment use case example: you can place a list fragment on the left and a

detail fragment on the right.

Page 38: DevFest Sul 2014 - Android 4 lazy iOS Devs

Fragments

Fragments allow you to break up your UI and controller logic into smaller, reusable chunks.

Page 39: DevFest Sul 2014 - Android 4 lazy iOS Devs

List Views and Adapters

ListViews are the closest approximation to UITableView on Android, and they are one of the most common components that you will

use.

Page 40: DevFest Sul 2014 - Android 4 lazy iOS Devs

List Views and Adapters

Like UITableView has a helper view controller, UITableViewController, ListView also has a

helper activity, ListActivity, and a helper fragment, ListFragment.

Page 41: DevFest Sul 2014 - Android 4 lazy iOS Devs

List Views and Adapters

On Android we don’t have datasources and delegates for ListView.

Page 42: DevFest Sul 2014 - Android 4 lazy iOS Devs

List Views and Adapters

We have adapters. Adapters come in many forms, but their primary goal is similar to a

datasource and table view delegate all in one.

Page 43: DevFest Sul 2014 - Android 4 lazy iOS Devs

List Views and Adapters

Adapters take data and adapt it to populate a ListView by instantiating views the ListView

will display

Page 44: DevFest Sul 2014 - Android 4 lazy iOS Devs

AsyncTasks

In place of Grand Central Dispatch on iOS, on Android we have access to AsyncTasks.

Page 45: DevFest Sul 2014 - Android 4 lazy iOS Devs

AsyncTasks

AsyncTasks is a different take on exposing asynchronous tools in a more friendly way.

Page 46: DevFest Sul 2014 - Android 4 lazy iOS Devs

Layout

The primary structure that you will deal with will be subclasses of ViewGroup –

RelativeLayout, LinearLayout, and FrameLayout are the most common.

Page 47: DevFest Sul 2014 - Android 4 lazy iOS Devs

Layout

Always work in dp (density-independent pixels) instead of pixels directly.

Page 48: DevFest Sul 2014 - Android 4 lazy iOS Devs

Data

The Data Storage Options available on Android are also very similar to what is available on iOS

Page 49: DevFest Sul 2014 - Android 4 lazy iOS Devs

Data

Shared Preferences <-> NSUserDefaults

Page 50: DevFest Sul 2014 - Android 4 lazy iOS Devs

Data

Saving to and fetching from file structure via the internal or external file storage <-> saving

to the documents directory

Page 51: DevFest Sul 2014 - Android 4 lazy iOS Devs

Data

SQLite <-> Core Data

Page 52: DevFest Sul 2014 - Android 4 lazy iOS Devs

Data

Android offers straight access to the SQLite database and returns cursor objects for results

Page 53: DevFest Sul 2014 - Android 4 lazy iOS Devs

IBOutlet

If you are anything like me you forget to connect IBOutlets at least 50% of the time

every time.

Page 54: DevFest Sul 2014 - Android 4 lazy iOS Devs

IBOutlet

With Android every view/component has a unique ID, something like:

@+id/myButton

Button button = (Button)findViewById(R.id.myButton);

Page 55: DevFest Sul 2014 - Android 4 lazy iOS Devs

NSLog

Log seems to be the go to solution here, you can specify debug, verbose etc.

System.out.println(..) also seems to do the job.

Page 56: DevFest Sul 2014 - Android 4 lazy iOS Devs

Paid Apple $99 developer fee

x

Paid Google $25 developer fee

Page 57: DevFest Sul 2014 - Android 4 lazy iOS Devs

$25 fee in Play Store.

75% cheaper than Apple's yearly fee.

Page 58: DevFest Sul 2014 - Android 4 lazy iOS Devs

Payments handled through Google Checkout.

Page 59: DevFest Sul 2014 - Android 4 lazy iOS Devs

Referenceshttp://www.objc.io/issue-11/android_101_for_ios_developers.html

http://www.bignerdranch.com/blog/learning-android-development-ios-developers-perspective/

http://stuartkhall.com/posts/android-development-tips-for-ios-devs

http://clayallsopp.com/android/9-uploading-to-market.html

http://developer.android.com/design/patterns/pure-android.html

http://www.prnewswire.com/news-releases/strategy-analytics-android-captures-79-percent-share-of-global-smartphone-shipments-in-2013-242563381.html

Page 60: DevFest Sul 2014 - Android 4 lazy iOS Devs

@jacksonfdam

Thank you