Upgrade to Pro — share decks privately, control downloads, hide ads and more …

From iOS to Android(or reverse)

From iOS to Android(or reverse)

From iOS to Android(or reverse)

7c4b1ae16723b56facc7a8a8f95aa6ce?s=128

jmortegac

April 26, 2015
Tweet

Transcript

  1. MADRID · NOV 21-22 · 2014 From iOS To Android(or

    reverse) José Manuel Ortega Candel @jmortegac http://www.linkedin.com/jmortega1
  2. MADRID · NOV 21-22 · 2014 https://speakerdeck.com/jmortega/

  3. 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
  4. MADRID · NOV 21-22 · 2014 ARCHITECTURE

  5. 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
  6. MADRID · NOV 21-22 · 2014 iOS Architecture

  7. MADRID · NOV 21-22 · 2014 TOOLS

  8. MADRID · NOV 21-22 · 2014 IDES Android iOS https://developer.android.com/sdk/

    installing/studio.html APPCode http://www.jetbrains.com/objc/
  9. MADRID · NOV 21-22 · 2014 on Android Studio 

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

  11. MADRID · NOV 21-22 · 2014 Android Studio  Project

    settings
  12. MADRID · NOV 21-22 · 2014 XCode  Provides multiple

    ios app templates
  13. MADRID · NOV 21-22 · 2014 Xcode Project  Testing

    on device  Base SDK
  14. MADRID · NOV 21-22 · 2014 Interface Builder

  15. 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
  16. MADRID · NOV 21-22 · 2014 APPLICATIONS

  17. MADRID · NOV 21-22 · 2014 Android Applications

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

    Preview
  19. 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
  20. MADRID · NOV 21-22 · 2014 Android components

  21. MADRID · NOV 21-22 · 2014 Android’s RecyclerView  Adapter

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

  23. MADRID · NOV 21-22 · 2014 Layout Systems UINavigationBar UITableView

    TextView TextView LinearLayout TextView TextView
  24. MADRID · NOV 21-22 · 2014 LifeCycle Applications

  25. MADRID · NOV 21-22 · 2014 LifeCycle Applications - (BOOL)application:(UIApplication

    *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window.rootViewController = self.navigationController; [self.window makeKeyAndVisible]; return YES; }
  26. 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
  27. 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"]
  28. 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
  29. 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
  30. MADRID · NOV 21-22 · 2014 iOS Applications  UIViewController

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

  32. MADRID · NOV 21-22 · 2014 iOS Applications  Snippets

    in XCode
  33. MADRID · NOV 21-22 · 2014 iOS Applications

  34. MADRID · NOV 21-22 · 2014 iOS Applications #import <UIKit/UIKit.h>

    @interface MyViewController : UIViewController <UITableViewDataSource, UITableViewDelegate>{ 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]; }
  35. MADRID · NOV 21-22 · 2014 iOS Applications  UINavigationController

  36. 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]; }
  37. 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.
  38. MADRID · NOV 21-22 · 2014 ViewPager / UIPageViewController 

    Swipe gesture
  39. MADRID · NOV 21-22 · 2014 Multilanguage NSString *localizedString =

    NSLocalizedString(@"Hello",@“DefaultString");
  40. 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
  41. MADRID · NOV 21-22 · 2014 Android Studio  Export

    + Sign APK
  42. MADRID · NOV 21-22 · 2014 PERMISSIONS

  43. MADRID · NOV 21-22 · 2014 Permissions on Android 

    AndroidManifest.xml  Protection mechanism to interact with other applications <uses--‐permission android:name="android.permission.INTERNET"/> <uses--‐permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <uses--‐permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> <uses--‐permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <uses--‐permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
  44. 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.
  45. MADRID · NOV 21-22 · 2014 Permissions on iOS 

    Privacy Analysis Tools for iOs Applications  patia.unileon.es
  46. MADRID · NOV 21-22 · 2014 Privacy Permission Manager

  47. MADRID · NOV 21-22 · 2014 USER INTERFACE

  48. MADRID · NOV 21-22 · 2014 Evolution

  49. MADRID · NOV 21-22 · 2014 Android Material design 

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

    Ldrawer  https://github.com/kanytu/android-material-drawer-template https://github.com/IkiMuhendis/LDrawer <?xml version="1.0" encoding="utf-8"?> <resources> <style name="AppTheme" parent="android:Theme.Material.Light"> <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> </style> </resources>
  51. MADRID · NOV 21-22 · 2014 Android Material design 

    https://github.com/google/iosched
  52. 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
  53. MADRID · NOV 21-22 · 2014 Android Fragments

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

     UISplitViewController
  55. MADRID · NOV 21-22 · 2014 Notifications

  56. MADRID · NOV 21-22 · 2014 STATIC ANALYSIS CODE

  57. MADRID · NOV 21-22 · 2014 Static analysis code on

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

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

    XCode  Static Analyzer  Detect memory leaks
  60. MADRID · NOV 21-22 · 2014 TESTING

  61. MADRID · NOV 21-22 · 2014 Mobile Application Testing TYPES

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

  63. 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
  64. MADRID · NOV 21-22 · 2014 Testing on Android 

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

     XCTest #import <XCTest/XCTest.h> #import “TestObject.h" @interface TestOjectLogicTests : XCTestCase { @private TestObject *object; } @end
  66. MADRID · NOV 21-22 · 2014 EMULATORS

  67. 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
  68. MADRID · NOV 21-22 · 2014 Genymotion  Integration with

    Eclipse and Android Studio  MULTI OS Compatible with Linux,Windows and Mac  Requires VirtualBox
  69. MADRID · NOV 21-22 · 2014 Alternatives  http://jimulabs.com/ for

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

  71. 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
  72. MADRID · NOV 21-22 · 2014 ARC  Migrating to

    ARC  Project Build Settings
  73. MADRID · NOV 21-22 · 2014 DATA PERSISTENCE

  74. MADRID · NOV 21-22 · 2014 Android iOS SQLite android.database.sqlite

     Tables and relations Core Data  Objects  DataModel Content Providers /data/data/<Application-Package> /databases/<database-name> Only acces with root DataModel editor in Xcode for register objects and their relationships
  75. MADRID · NOV 21-22 · 2014 iOS Core Data

  76. MADRID · NOV 21-22 · 2014 Alernatives http://realm.io/ Android and

    iOS Object-oriented API C++ Core
  77. MADRID · NOV 21-22 · 2014 SHARED ACTIONS

  78. MADRID · NOV 21-22 · 2014 Android <?xml version="1.0" encoding="utf-8"?>

    <menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/share" android:title="@string/share" android:showAsAction="ifRoom" android:actionProviderClass="android.widget.ShareActionProvider"/> </menu> 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;}
  79. 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
  80. MADRID · NOV 21-22 · 2014 CHECK CONNECTIVITY

  81. MADRID · NOV 21-22 · 2014 Check connectivity on Android

     ConnectivityManager <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.INTERNET" /> public static boolean checkConnectivity(Context context) { ConnectivityManager cm =(ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); return activeNetwork != null && activeNetwork.isConnectedOrConnecting(); }
  82. 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 }
  83. MADRID · NOV 21-22 · 2014 APP PUBLISHING

  84. 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/
  85. MADRID · NOV 21-22 · 2014  Distribution

  86. MADRID · NOV 21-22 · 2014 Developers Library

  87. 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/
  88. MADRID · NOV 21-22 · 2014 https://play.google.com/store/apps/details?id=com.desarrollodroide.repos  Android libraries

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

    library
  90. 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
  91. MADRID · NOV 21-22 · 2014 BOOKS

  92. MADRID · NOV 21-22 · 2014

  93. 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/
  94. MADRID · NOV 21-22 · 2014 Thanks Questions?