DevFest Sul 2014 - Android 4 lazy iOS Devs
-
Upload
jackson-mafra -
Category
Mobile
-
view
266 -
download
0
description
Transcript of DevFest Sul 2014 - Android 4 lazy iOS Devs
Give yourself to the Dark Side!
Jackson F. de A. Mafra
http://developer.android.com/design/index.html
follow this, seriously!
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.
No More Menu Button
New Buttons
Notifications
Navigation
ActionBar
ActionBar
MultiPane
Dialogs
Android is not iOS
Android is not iOS
IDE
Android Studio
or
(Eclipse ADT plugin)
Android SDK and AVD Manager
Language Application Structure
There are many differences between Objective-C and Java
Java
Say what you will about Java, in the end it's just another language. Be thankful there is no J2EE
in sight.
Language Application Structure
Referencing this.object will not call your custom getter. You must use this.getObject.
Language Application Structure
Java methods are typically written as actions or queries, such as getCell(), instead of
cellForRowAtIndexPath:.
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.
Project Structure
Android applications are primarily broken into two sections, the first of which is the Java
source code.
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).
Project Structure
The second major section is the res folder, short for ‘resource’ folder.
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.
Project Structure
Android uses Layouts which are xml. They are completely independent from each other.
Android Studio also has a nice WYSIWYG editor
Project Structure
On iOS, images are either @2x or not, but on Android there are a number of screen density
folders to consider.
Project Structure
Android uses folders to arrange images, strings, and other values for screen density.
Project Structure
One last correlation in project structure is the AndroidManifest.xml file.
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.
Activities
Activities are the basic visual unit of an Android app, just as UIViewControllers are
the basic visual component on iOS.
Activities
Instead of a UINavigationController, the Android OS keeps an activity stack that it
manages.
Activities
In essence, the activity lifecycle is very similar to the UIViewController lifecycle.
Activities
Fragments
The Fragment concept is unique to Android and came around somewhat recently in
Android 3.0 (2010).
Fragments
Fragments are mini controllers that can be instantiated to fill activities.
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.
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.
Fragments
Fragments allow you to break up your UI and controller logic into smaller, reusable chunks.
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.
List Views and Adapters
Like UITableView has a helper view controller, UITableViewController, ListView also has a
helper activity, ListActivity, and a helper fragment, ListFragment.
List Views and Adapters
On Android we don’t have datasources and delegates for ListView.
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.
List Views and Adapters
Adapters take data and adapt it to populate a ListView by instantiating views the ListView
will display
AsyncTasks
In place of Grand Central Dispatch on iOS, on Android we have access to AsyncTasks.
AsyncTasks
AsyncTasks is a different take on exposing asynchronous tools in a more friendly way.
Layout
The primary structure that you will deal with will be subclasses of ViewGroup –
RelativeLayout, LinearLayout, and FrameLayout are the most common.
Layout
Always work in dp (density-independent pixels) instead of pixels directly.
Data
The Data Storage Options available on Android are also very similar to what is available on iOS
Data
Shared Preferences <-> NSUserDefaults
Data
Saving to and fetching from file structure via the internal or external file storage <-> saving
to the documents directory
Data
SQLite <-> Core Data
Data
Android offers straight access to the SQLite database and returns cursor objects for results
IBOutlet
If you are anything like me you forget to connect IBOutlets at least 50% of the time
every time.
IBOutlet
With Android every view/component has a unique ID, something like:
@+id/myButton
Button button = (Button)findViewById(R.id.myButton);
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.
Paid Apple $99 developer fee
x
Paid Google $25 developer fee
$25 fee in Play Store.
75% cheaper than Apple's yearly fee.
Payments handled through Google Checkout.
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
@jacksonfdam
Thank you