Slide 1

Slide 1 text

MADRID · NOV 21-22 · 2014 From iOS To Android(or reverse) José Manuel Ortega Candel @jmortegac http://www.linkedin.com/jmortega1

Slide 2

Slide 2 text

MADRID · NOV 21-22 · 2014 https://speakerdeck.com/jmortega/

Slide 3

Slide 3 text

MADRID · NOV 21-22 · 2014 ARCHITECTURE / iOS / ANDROID TOOLS XCODE vs ANDROID STUDIO APPLICATIONS / PERMISSIONS / PRIVACY USER INTERFACE STATIC ANALYSIS CODE / TESTING CERTIFICATES AND SIGNING EMULATORS / MEMORY MANAGEMENT/ DATABASE APP PUBLISHING / DEVELOPER LIBRARIES

Slide 4

Slide 4 text

MADRID · NOV 21-22 · 2014 ARCHITECTURE

Slide 5

Slide 5 text

MADRID · NOV 21-22 · 2014 Android Architecture DALVIK ART Just-In-Time (JIT) Compilation Ahead-Of-Time (AOT) Compilation Cache builds up over time Boot times are faster Cache is built at first boot Rebooting device takes significantly longer Apps compiled when executed Stores Compiled Apps Consumes much more internal storage space

Slide 6

Slide 6 text

MADRID · NOV 21-22 · 2014 iOS Architecture

Slide 7

Slide 7 text

MADRID · NOV 21-22 · 2014 TOOLS

Slide 8

Slide 8 text

MADRID · NOV 21-22 · 2014 IDES Android iOS https://developer.android.com/sdk/ installing/studio.html APPCode http://www.jetbrains.com/objc/

Slide 9

Slide 9 text

MADRID · NOV 21-22 · 2014 on Android Studio  InteliJ IDE Based  Maven based Build Dependency  Combines Ant && Maven / Gradle Tasks

Slide 10

Slide 10 text

MADRID · NOV 21-22 · 2014 Android Studio  Templates

Slide 11

Slide 11 text

MADRID · NOV 21-22 · 2014 Android Studio  Project settings

Slide 12

Slide 12 text

MADRID · NOV 21-22 · 2014 XCode  Provides multiple ios app templates

Slide 13

Slide 13 text

MADRID · NOV 21-22 · 2014 Xcode Project  Testing on device  Base SDK

Slide 14

Slide 14 text

MADRID · NOV 21-22 · 2014 Interface Builder

Slide 15

Slide 15 text

MADRID · NOV 21-22 · 2014 Instruments on iOS  Debugging, performance analysis, and testing  Real-time CPU, memory, disk, energy, and network usage  Threads, network, and energy usage  I/O system and thread activity  Allows detecting memory leaks

Slide 16

Slide 16 text

MADRID · NOV 21-22 · 2014 APPLICATIONS

Slide 17

Slide 17 text

MADRID · NOV 21-22 · 2014 Android Applications

Slide 18

Slide 18 text

MADRID · NOV 21-22 · 2014 Android Layout Manager+ Device Preview

Slide 19

Slide 19 text

MADRID · NOV 21-22 · 2014 Android Applications import android.os.Bundle; import android.app.Activity; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);} } public static void invokeWebBrowser(Activity activity){ Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("http://www.google.com")); activity.startActivity(intent); }  Activity  Intents [Explicit,Implicits]  Services  Content Providers[Sharing data between apps]  Fragments from 3.0

Slide 20

Slide 20 text

MADRID · NOV 21-22 · 2014 Android components

Slide 21

Slide 21 text

MADRID · NOV 21-22 · 2014 Android’s RecyclerView  Adapter  ViewHolder  LayoutManager  ItemDecoration  ItemAnimator https://developer.android.com/training/material/lists-cards.html

Slide 22

Slide 22 text

MADRID · NOV 21-22 · 2014 Android Navigation Drawer

Slide 23

Slide 23 text

MADRID · NOV 21-22 · 2014 Layout Systems UINavigationBar UITableView TextView TextView LinearLayout TextView TextView

Slide 24

Slide 24 text

MADRID · NOV 21-22 · 2014 LifeCycle Applications

Slide 25

Slide 25 text

MADRID · NOV 21-22 · 2014 LifeCycle Applications - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window.rootViewController = self.navigationController; [self.window makeKeyAndVisible]; return YES; }

Slide 26

Slide 26 text

MADRID · NOV 21-22 · 2014 iOS Applications  C  Objective –C,[message passing]  Swift  PlayGround for leaning Swift  Programming with Objetive-C in windows/ linux  http://www.gnustep.org/ https://developer.apple.com/swift

Slide 27

Slide 27 text

MADRID · NOV 21-22 · 2014 Objective-C vs Swift NSString *string = @“hello”; let string = "hello" as NSString let s: NSString = "hello" var string: NSString = "hello" string= "Hello" NSLog(@“This is a string”); println("This is a string"); NSArray *myArray = [NSArray arrayWithObjects:@“string1", @“string2", nil]; var myArray = [“string1", "string2"] var myArray : [String] = [“string1", "string2"]

Slide 28

Slide 28 text

MADRID · NOV 21-22 · 2014 iOS Applications  @synthesize will generate getter and setter methods for your @property @interface MyObject:NSObject { NSString *_name; } @property (nonatomic,assign) NSString* name; @end @implementation MyObject @synthesize name = _ name; @end

Slide 29

Slide 29 text

MADRID · NOV 21-22 · 2014 UIKit Framework  UIButton  UILabel  UIImageView  UITextField  UIPickerView  UIWindow  UIView  UIViewController  NSObject,NSString,NSMutableString, NSDate,NSNumber  Collections(NSArray, NSDictionary, NSSet,NSEnumerator) Foundation Framework

Slide 30

Slide 30 text

MADRID · NOV 21-22 · 2014 iOS Applications  UIViewController is the parent for view Controllers

Slide 31

Slide 31 text

MADRID · NOV 21-22 · 2014 iOS Applications  Organizer

Slide 32

Slide 32 text

MADRID · NOV 21-22 · 2014 iOS Applications  Snippets in XCode

Slide 33

Slide 33 text

MADRID · NOV 21-22 · 2014 iOS Applications

Slide 34

Slide 34 text

MADRID · NOV 21-22 · 2014 iOS Applications #import @interface MyViewController : UIViewController { IBOutlet UITableView *table; NSMutableData *dataReceive; } @property(nonatomic,assign) NSMutableData *dataReceive; @end  UIViewController interface MyViewController.h  implementation MyViewController.m @implementation MyViewController @synthesize dataReceive,table; - (void)viewDidLoad{ [super viewDidLoad]; NSURL *url = [[NSURL alloc] initWithString:@“url"]; self.dataReceive = [[NSMutableData data] retain]; }

Slide 35

Slide 35 text

MADRID · NOV 21-22 · 2014 iOS Applications  UINavigationController

Slide 36

Slide 36 text

MADRID · NOV 21-22 · 2014 iOS Applications  UINavigationController - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; //Recuperamos el ViewController UIViewController *rootViewController = [storyboard instantiateInitialViewController]; // Creamos un UINavigationController, que se encargará de controlar y almacenar los distintos viewControllers de nuestra aplicación. UINavigationController *navigationController = [[UINavigationController alloc]initWithRootViewController:rootViewController]; //Asignamos el navigationController como principal. self.window.rootViewController = navigationController; return YES; } -(IBAction)goToPantalla2:(id)sender { UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; //Obtenemos el controlador con Identifier "Pantalla2" Pantalla2ViewController *pantalla2Controller = [storyBoard instantiateViewControllerWithIdentifier:@"Pantalla2"]; //Lanzamos el controlador en el navigation de forma animada: [self.navigationController pushViewController:pantalla2Controller animated:YES]; }

Slide 37

Slide 37 text

MADRID · NOV 21-22 · 2014 Design patterns on iOS Applications  MVC  Target-action  Delegate and protocols A delegate is an object that control of the user interface for that event.

Slide 38

Slide 38 text

MADRID · NOV 21-22 · 2014 ViewPager / UIPageViewController  Swipe gesture

Slide 39

Slide 39 text

MADRID · NOV 21-22 · 2014 Multilanguage NSString *localizedString = NSLocalizedString(@"Hello",@“DefaultString");

Slide 40

Slide 40 text

MADRID · NOV 21-22 · 2014 Certificates and Signing Android iOS Self-signed certificate Apps are signed by developers Apple certificate Apps are signed by Apple Java Keytool Generate a distribution provisioning profile Export + Sign APK iOS Provisioning Portal Debug and distribution certificate App ID (unique ID of your app) Set of device unique identifiers Developer certificate

Slide 41

Slide 41 text

MADRID · NOV 21-22 · 2014 Android Studio  Export + Sign APK

Slide 42

Slide 42 text

MADRID · NOV 21-22 · 2014 PERMISSIONS

Slide 43

Slide 43 text

MADRID · NOV 21-22 · 2014 Permissions on Android  AndroidManifest.xml  Protection mechanism to interact with other applications

Slide 44

Slide 44 text

MADRID · NOV 21-22 · 2014 Permissions on iOS o Declare your application requirements in its manifest-like Info.plist. This is used only for ensuring device compatibility. o UIRequiredDeviceCapabilities allows you to list ’hardware-like’ capabilities that your app needs. o AppStore reads this information for filter installer devices.

Slide 45

Slide 45 text

MADRID · NOV 21-22 · 2014 Permissions on iOS  Privacy Analysis Tools for iOs Applications  patia.unileon.es

Slide 46

Slide 46 text

MADRID · NOV 21-22 · 2014 Privacy Permission Manager

Slide 47

Slide 47 text

MADRID · NOV 21-22 · 2014 USER INTERFACE

Slide 48

Slide 48 text

MADRID · NOV 21-22 · 2014 Evolution

Slide 49

Slide 49 text

MADRID · NOV 21-22 · 2014 Android Material design  Minimalist and consistency  Transitions, animiations  Cards https://developer.android.com/training/material/get-started.html

Slide 50

Slide 50 text

MADRID · NOV 21-22 · 2014 Android Material design  Ldrawer  https://github.com/kanytu/android-material-drawer-template https://github.com/IkiMuhendis/LDrawer <item name="android:colorPrimary"> @color/primary</item> <item name="android:colorPrimaryDark"> @color/primary_dark</item> <item name="android:colorAccent"> @color/accent</item> <item name="android:textColorPrimary"> @color/text_primary</item> <item name="android:textColor"> @color/text_secondary</item> <item name="android:navigationBarColor"> @color/primary_dark</item>

Slide 51

Slide 51 text

MADRID · NOV 21-22 · 2014 Android Material design  https://github.com/google/iosched

Slide 52

Slide 52 text

MADRID · NOV 21-22 · 2014 Android Fragments  Fragment is a chunk of user interface with its own life cycle.  Fragment must exist within an Activity  Interaction with fragments is done through FragmentManager  Fragment API was introduced in API 11  http://developer.android.com/tools/support-library

Slide 53

Slide 53 text

MADRID · NOV 21-22 · 2014 Android Fragments

Slide 54

Slide 54 text

MADRID · NOV 21-22 · 2014 iOS  Master-Detail template  UISplitViewController

Slide 55

Slide 55 text

MADRID · NOV 21-22 · 2014 Notifications

Slide 56

Slide 56 text

MADRID · NOV 21-22 · 2014 STATIC ANALYSIS CODE

Slide 57

Slide 57 text

MADRID · NOV 21-22 · 2014 Static analysis code on Android Studio  Inspect Profile  Lint

Slide 58

Slide 58 text

MADRID · NOV 21-22 · 2014 Static analysis code on Java projects  SonarQube  Sonnar-runner

Slide 59

Slide 59 text

MADRID · NOV 21-22 · 2014 Static analysis code on XCode  Static Analyzer  Detect memory leaks

Slide 60

Slide 60 text

MADRID · NOV 21-22 · 2014 TESTING

Slide 61

Slide 61 text

MADRID · NOV 21-22 · 2014 Mobile Application Testing TYPES Unit Testing Functionality Testing Integration Testing Regression Load Testing Stress Testing Performance Usability Testing

Slide 62

Slide 62 text

MADRID · NOV 21-22 · 2014 Mobile Application Testing

Slide 63

Slide 63 text

MADRID · NOV 21-22 · 2014 CheckList  Rotating the screen  Behavior of when network is not available  Navigation between screens  Behavior of app if app is running for longer period of time and checking memory

Slide 64

Slide 64 text

MADRID · NOV 21-22 · 2014 Testing on Android  Unit & Integration,TDD  Junit  RoboElectric  Acceptance,BDD  RobotiumTesting User Interface  Calabash

Slide 65

Slide 65 text

MADRID · NOV 21-22 · 2014 Unit testing on iOS  XCTest #import #import “TestObject.h" @interface TestOjectLogicTests : XCTestCase { @private TestObject *object; } @end

Slide 66

Slide 66 text

MADRID · NOV 21-22 · 2014 EMULATORS

Slide 67

Slide 67 text

MADRID · NOV 21-22 · 2014 Emulator vs Simulator Android iOS Emulator Simulator Very slow integrated with SDK Integrated with Xcode Emulates hardware and software Simulates only software Launched apps are equal binaries from the apps compiled for Device CPU Launched apps are different binaries from the apps compiled for Device CPU

Slide 68

Slide 68 text

MADRID · NOV 21-22 · 2014 Genymotion  Integration with Eclipse and Android Studio  MULTI OS Compatible with Linux,Windows and Mac  Requires VirtualBox

Slide 69

Slide 69 text

MADRID · NOV 21-22 · 2014 Alternatives  http://jimulabs.com/ for Android live preview  https://appthwack.com/ for testing in the cloud with real devices

Slide 70

Slide 70 text

MADRID · NOV 21-22 · 2014 MEMORY MANAGEMENT

Slide 71

Slide 71 text

MADRID · NOV 21-22 · 2014  Android Handles memory management automatically Garbage Collector  iOS release, retain, autorelease ARC(Automatic Reference Counting)  Developer maintain the count number for each object  Destroys object when reference counting become 0  @autoreleasepool  With ARC, compiler set this methods where its necessary

Slide 72

Slide 72 text

MADRID · NOV 21-22 · 2014 ARC  Migrating to ARC  Project Build Settings

Slide 73

Slide 73 text

MADRID · NOV 21-22 · 2014 DATA PERSISTENCE

Slide 74

Slide 74 text

MADRID · NOV 21-22 · 2014 Android iOS SQLite android.database.sqlite  Tables and relations Core Data  Objects  DataModel Content Providers /data/data/ /databases/ Only acces with root DataModel editor in Xcode for register objects and their relationships

Slide 75

Slide 75 text

MADRID · NOV 21-22 · 2014 iOS Core Data

Slide 76

Slide 76 text

MADRID · NOV 21-22 · 2014 Alernatives http://realm.io/ Android and iOS Object-oriented API C++ Core

Slide 77

Slide 77 text

MADRID · NOV 21-22 · 2014 SHARED ACTIONS

Slide 78

Slide 78 text

MADRID · NOV 21-22 · 2014 Android private ShareActionProvider mShareActionProvider; mShareActionProvider.setShareIntent(getDefaultShareIntent()); private Intent getDefaultShareIntent(){ Intent intent = new Intent(Intent.ACTION_SEND); //IMPLICIT INTENT intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT,"Extra Text"); return intent;}

Slide 79

Slide 79 text

MADRID · NOV 21-22 · 2014 iOS - (IBAction)shareButton:(UIBarButtonItem *)sender { NSString *textToShare = @“textToShare"; UIImage *imageToShare = [UIImage imageNamed:@"yourImage.png"]; NSURL *myWebsite = [NSURL URLWithString:@"http://www.example.com/"]; NSArray *objectsToShare = @[textToShare, imageToShare ,myWebsite]; UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:objectsToShare applicationActivities:nil]; NSArray *excludeActivities = @[UIActivityTypeAirDrop,UIActivityTypePrint]; activityVC.excludedActivityTypes = excludeActivities; [self presentViewController:activityVC animated:YES completion:nil]; }  UIActivityViewController

Slide 80

Slide 80 text

MADRID · NOV 21-22 · 2014 CHECK CONNECTIVITY

Slide 81

Slide 81 text

MADRID · NOV 21-22 · 2014 Check connectivity on Android  ConnectivityManager public static boolean checkConnectivity(Context context) { ConnectivityManager cm =(ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); return activeNetwork != null && activeNetwork.isConnectedOrConnecting(); }

Slide 82

Slide 82 text

MADRID · NOV 21-22 · 2014 Check connectivity on iOS  Reachability internetReach = [[Reachability reachabilityForInternetConnection] retain]; [internetReach startNotifier]; if([internetReach currentReachabilityStatus] == ReachableViaWWAN) { // Tenemos conexión a Internet } wifiReach = [[Reachability reachabilityForLocalWiFi] retain]; [wifiReach startNotifier]; if([wifiReach currentReachabilityStatus] == ReachableViaWiFi) { // Estamos conectados mediante Wi-Fi }

Slide 83

Slide 83 text

MADRID · NOV 21-22 · 2014 APP PUBLISHING

Slide 84

Slide 84 text

MADRID · NOV 21-22 · 2014 Android iOS Google requires a one time fee of US$25 iOS Developer Program $99 /year Greater capacity for monetization Google play + Publish in other stores like Amazon,Opera AppStore Alpha/beta testing before put in production Upload to store in 30 min Review process 5-7 days Android Developer Console Beta Testing http://ibetatest.com/ http://testflightapp.com/

Slide 85

Slide 85 text

MADRID · NOV 21-22 · 2014  Distribution

Slide 86

Slide 86 text

MADRID · NOV 21-22 · 2014 Developers Library

Slide 87

Slide 87 text

MADRID · NOV 21-22 · 2014 Async connections  iOS  Thread managed by NSURLConnection  Android  Services, AsyncTask  Libraries for Android  Otto Event Bus,RoboSpice  http://square.github.io/otto/

Slide 88

Slide 88 text

MADRID · NOV 21-22 · 2014 https://play.google.com/store/apps/details?id=com.desarrollodroide.repos  Android libraries with demos in GP

Slide 89

Slide 89 text

MADRID · NOV 21-22 · 2014 https://developer.apple.com/library/ios/navigation/  iOS Developer library

Slide 90

Slide 90 text

MADRID · NOV 21-22 · 2014  Classes comparative iOS Android Base UIApplication Application Controller UIViewController Activity/Fragment Event Emitter Target Action/Responder Chain Event Listener i.e. onClick() Data Saving NSUserDefaults / SQLite SharedPreferences / SQLite Multi Thread NSThread Thread/AsyncTask/Service Internationalization NSLocalizedString Resource files GPS CoreLocation LocationManager for MapView, use Google SDK Accelerometer UIAccelerometer SensorManager Local Notification UILocalNotification NotificationManager Remote Push Notification Apple Push Notifiation Service C2DM (external package) com.google.android.c2dm

Slide 91

Slide 91 text

MADRID · NOV 21-22 · 2014 BOOKS

Slide 92

Slide 92 text

MADRID · NOV 21-22 · 2014

Slide 93

Slide 93 text

MADRID · NOV 21-22 · 2014 References o www.developer.android.com o http://www.google.com/design/spec/material-design/ introduction.html o http://tools.android.com/ o https://android-arsenal.com/ o http://android-developers.blogspot.com.es/ o www.developer.apple.com o https://developer.apple.com/videos/wwdc/ o https://developer.apple.com/library/ios/referencelibrary/Getting Started/RoadMapiOS/

Slide 94

Slide 94 text

MADRID · NOV 21-22 · 2014 Thanks Questions?