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

iOSアプリエンジニアのためのAndroidアプリ開発

cockscomb
December 03, 2015

 iOSアプリエンジニアのためのAndroidアプリ開発

Presented at Cocoa勉強会関西64 #cocoa_kansai

cockscomb

December 03, 2015
Tweet

More Decks by cockscomb

Other Decks in Programming

Transcript

  1. iOSΞϓϦΤϯδχΞͷͨΊͷ

    AndroidΞϓϦ։ൃ

    View Slide

  2. cockscomb

    View Slide

  3. Hiroki Kato

    View Slide

  4. View Slide

  5. iOSΞϓϦΤϯδχΞͷͨΊͷ

    AndroidΞϓϦ։ൃ

    View Slide

  6. iOS Android

    View Slide

  7. ։ൃ؀ڥ
    Xcode
    iOS Simulator
    App Store
    Android Studio
    Emulator
    Google Play
    OSS
    iOS Android

    View Slide

  8. ϓϥοτϑΥʔϜ
    Mac (OS X)
    iPhone/iPad (iOS)
    Car Play
    Apple Watch (watchOS)
    Apple TV (tvOS)
    Phone/Tablet
    Android Wear
    Android TV
    Android Auto
    iOS Android

    View Slide

  9. ։ൃݴޠ
    Swift
    Objective-C
    Java
    (Kotlin)
    iOS Android

    View Slide

  10. Ϗϧυ
    xcodebuild
    ґଘ؅ཧ
    CocoaPods
    Carthage
    gradle
    iOS Android

    View Slide

  11. gradle
    • Ϗϧυπʔϧ
    • build.gradleϑΝΠϧ
    • Android Studio͕αϙʔτ
    • ίϚϯυϥΠϯ͔Β΋ར༻Ͱ͖Δ
    Android

    View Slide

  12. όʔδϣχϯά
    iOS 9
    iOS 8
    Earlier
    6.0 (Marshmallow)
    5.1 (Lollipop)
    5.0 (Lollipop)
    4.4 (Kitkat)
    4.3 (Jelly Bean)
    4.2 (Jelly Bean)
    4.1 (Jelly Bean)
    4.0 (Ice Cream Sandwich)
    Android

    View Slide

  13. API Level
    Version Version Code API Level
    6.0 MARSHMALLOW 23
    5.1 LOLLIPOP_MR1 22
    5.0 LOLLIPOP 21
    4.4W KITKAT_WATCH 20
    4.4 KITKAT 19
    4.3 JELLY_BEAN_MR2 18
    4.2 JELLY_BEAN_MR1 17
    4.1 JELLY_BEAN 16
    4.0.3, 4.0.4 ICE_CREAM_SANDWICH_MR1 15
    4.0, 4.0.1, 4.0.2 ICE_CREAM_SANDWICH 14
    Android

    View Slide

  14. Fragmentation
    Earlier
    9%
    iOS 8
    24%
    iOS 9
    67%
    Earlier
    4.0%
    Ice Cream Sandwich
    3.3%
    Jelly Bean
    29.0%
    Kitkat
    37.8%
    Lollipop
    25.6%
    Marshmallow
    0.3%
    iOS Android

    View Slide

  15. Fragmentation
    • Support Library
    • ࠷৽ػೳͷόοΫϙʔτ
    • Google Play Services
    • OSͱಠཱͨ͠API
    Android

    View Slide

  16. ΞϓϦͷೖޱ
    UIApplicationMain
    Storyboard
    AndroidManifest.xml
    iOS Android

    View Slide

  17. AndroidManifest
    xmlns:android="http://schemas.android.com/apk/res/android">

    android:icon="@mipmap/ic_launcher"

    android:label="@string/app_name"

    android:theme="@style/AppTheme">

    android:name=".MainActivity"

    android:label="@string/app_name"

    android:theme="@style/AppTheme.NoActionBar">



    android:name="android.intent.category.LAUNCHER"/>





    Android

    View Slide

  18. ը໘ͷߏ੒୯Ґ
    UIViewController
    Activity
    Fragment
    iOS Android

    View Slide

  19. Activity/Fragment
    • Activity
    • ը໘ʹͻͱ͚ͭͩ
    • Fragment
    • Activityʹ಺แͰ͖Δ
    Android

    View Slide

  20. ϥΠϑαΠΫϧ
    UIViewController
    init
    viewDidLoad
    viewWillAppear
    viewDidAppear
    viewWillDisappear
    viewDidDisappear
    deinit
    Activity
    onCreate
    onStart
    onRestoreInstanceState
    onResume
    onPause
    onSaveInstanceState
    onStop
    onDestroy
    iOS Android

    View Slide

  21. Activityͷ࠶ੜ੒
    • Activity͸࠶ੜ੒͞ΕΔ
    • ը໘ͷճసͳͲͷมԽʹىҼ
    • ঢ়ଶΛࣦΘͳ͍Α͏ʹ࡞Δ
    • onSaveInstanceState
    • Parcelable
    Android

    View Slide

  22. ը໘ભҠ
    showViewController
    UIStoryboardSegue
    Intent
    FragmentTransaction
    iOS Android

    View Slide

  23. Intent
    • ৽͍͠ActivityΛελʔτͰ͖Δ
    • γϦΞϥΠζՄೳͳύϥϝʔλ
    • ଞͷΞϓϦͷActivity΋ελʔτ
    • ҉໧తͳIntent
    Android

    View Slide

  24. Intent
    Intent intent = new Intent(this, MainActivity.class);

    intent.putExtra("extra_name_key", "cockscomb");

    startActivity(intent);
    Intent intent = new Intent(Intent.ACTION_VIEW,

    Uri.parse("http://example.com"));

    startActivity(intent);
    Android

    View Slide

  25. Ϗϡʔ
    UIView
    View
    ViewGroup
    iOS Android

    View Slide

  26. View/ViewGroup
    • View
    • ViewGroup
    • ViewΛ಺แͰ͖Δ
    • ಺แͨ͠ViewΛϨΠΞ΢τ͢Δ
    Android

    View Slide

  27. ༷ʑͳϏϡʔ
    UIView View
    UILabel/UITextView TextView
    UITextField/UITextView EditText
    UIImageView ImageView
    UIButton Button/ImageButton
    UIScrollView ScrollView
    UITableView/UICollectionView RecyclerView
    UIWebView/WKWebView WebView
    iOS Android

    View Slide

  28. ϨΠΞ΢τϑΝΠϧ
    Storyboard
    Nib (Xib)
    Layout XML
    iOS Android

    View Slide

  29. Layout XML
    xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical">

    android:id="@+id/user_name"

    android:layout_width="match_parent"

    android:layout_height="wrap_content"

    android:inputType="text"/>

    android:id="@+id/password"

    android:layout_width="match_parent"

    android:layout_height="wrap_content"

    android:inputType="textPassword"/>

    android:id="@+id/login_button"

    android:text="@string/action_sign_in"

    android:layout_width="match_parent"

    android:layout_height="wrap_content"/>


    Android

    View Slide

  30. Ϗϡʔͱͷ઀ଓ
    Target Action
    @IBAction
    @IBOutlet
    android:id
    OnClickListener
    Data Binding
    iOS Android

    View Slide

  31. Data Binding Library
    xmlns:android="http://schemas.android.com/apk/res/android">




    android:orientation="vertical"

    android:layout_width="match_parent"

    android:layout_height="match_parent">

    android:layout_height="wrap_content"

    android:text="@{user.firstName}"/>

    android:layout_height="wrap_content"

    android:text="@{user.lastName}"/>



    Android

    View Slide

  32. ϨΠΞ΢τͷํ๏
    Auto Layout
    Resizing Mask
    ViewGroup
    iOS Android

    View Slide

  33. ViewGroup
    • FrameLayout
    • LinearLayout
    • RelativeLayout
    • GridLayout
    Android

    View Slide

  34. αΠζຖͷ࠷దԽ
    Size Class
    Display Scale
    User Interface Idiom
    ໋໊نଇ
    ը໘ີ౓
    ີ౓ඇґଘϐΫηϧ
    iOS Android

    View Slide

  35. Ϧιʔεͷ໋໊نଇ
    • res/layout/login.xml
    • σϑΥϧτ
    • res/layout-sw800dp/login.xml
    • ը໘෯͕800dpҎ্
    • R.layout.login
    Android

    View Slide

  36. ը໘ີ౓
    • xxxhdpi — 4.0
    • xxhdpi — 3.0
    • xhdpi — 2.0
    • hdpi — 1.5
    • mdpi — 1.0
    • ldpi — 0.75
    Android

    View Slide

  37. ୯Ґ
    • dp (ີ౓ඇґଘϐΫηϧ)
    • 160dpi
    • sp (εέʔϧඇґଘϐΫηϧ)
    • ઃఆ͞ΕͨςΩεταΠζʹൺྫ
    Android

    View Slide

  38. ༷ʑͳϦιʔε
    Asset Catalog
    Strings
    etc.
    Drawable
    R.drawable.ic_hamburger
    Values
    R.color.darkTextColor
    R.string.login
    etc.
    iOS Android

    View Slide

  39. Ϧιʔε
    • XML΍PNG
    • छྨຖͷσΟϨΫτϦʹஔ͘
    • ϨΠΞ΢τ/ը૾/৭/αΠζ/Ξχϝʔ
    γϣϯ/ελΠϧ/จࣈྻ/ϝχϡʔ
    • R.xxx.yyy
    Android

    View Slide

  40. Drawable
    • BitmapDrawable
    • RoundedBitmapDrawable
    • NinePatchDrawable
    • ShapeDrawable
    • VectorDrawable
    • AnimatedVectorDrawable
    • ColorDrawable
    • GradientDrawable
    • LayerDrawable
    • RippleDrawable
    • LevelListDrawable
    • StateListDrawable
    • AnimationDrawable
    • ClipDrawable
    • InsetDrawable
    • RotateDrawable
    • ScaleDrawable
    • PictureDrawable
    Android

    View Slide

  41. ϑΝΠϧΞΫηε
    NSFileManager Context
    iOS Android

    View Slide

  42. Context
    • ΞϓϦͱ֎෦؀ڥΛܨ͙
    • Ϧιʔεͷऔಘ/ϑΝΠϧΞΫηε
    • Application/Activity/Service
    Android

    View Slide

  43. Service
    • ը໘ͱಠཱͨ͠ॲཧ
    • όοΫάϥ΢ϯυͰಈ࡞Ͱ͖Δ
    • IntentService
    Android

    View Slide

  44. ετϨʔδ
    File System
    Core Data
    SQLite
    Keychain
    Internal Storage
    External Storage
    SQLite
    AccountManager
    Key Store
    iOS Android

    View Slide

  45. ݖݶ
    PHPhotoLibrary

    .requestAuthorization(_:)
    ύʔϛογϣϯ
    iOS Android

    View Slide

  46. ύʔϛογϣϯ
    • android:name="android.permission.INTERNET" />
    • Runtime Permissions
    Android

    View Slide

  47. ڞ༗
    URL Scheme
    Open In
    Document Provider
    Extension
    Intent
    File System
    Content Provider
    iOS Android

    View Slide

  48. ςετ
    XCTest
    Unit Testing
    UI Testing
    Testing Support Library
    AndroidJUnitRunner
    Espresso
    UI Automator
    iOS Android

    View Slide

  49. iOS Android

    View Slide