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

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

58b40ae3b0db6cf0202a3802e9dd70fe?s=47 cockscomb
December 03, 2015

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

Presented at Cocoa勉強会関西64 #cocoa_kansai

58b40ae3b0db6cf0202a3802e9dd70fe?s=128

cockscomb

December 03, 2015
Tweet

Transcript

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

  2. cockscomb

  3. Hiroki Kato

  4. None
  5. iOSΞϓϦΤϯδχΞͷͨΊͷ
 AndroidΞϓϦ։ൃ

  6. iOS Android

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

    Play OSS iOS Android
  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
  9. ։ൃݴޠ Swift Objective-C Java (Kotlin) iOS Android

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

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

    Android
  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
  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
  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
  15. Fragmentation • Support Library • ࠷৽ػೳͷόοΫϙʔτ • Google Play Services

    • OSͱಠཱͨ͠API Android
  16. ΞϓϦͷೖޱ UIApplicationMain Storyboard AndroidManifest.xml iOS Android

  17. AndroidManifest <manifest package="info.cockscomb.myapplication"
 xmlns:android="http://schemas.android.com/apk/res/android">
 <application
 android:icon="@mipmap/ic_launcher"
 android:label="@string/app_name"
 android:theme="@style/AppTheme">
 <activity
 android:name=".MainActivity"


    android:label="@string/app_name"
 android:theme="@style/AppTheme.NoActionBar">
 <intent-filter>
 <action android:name="android.intent.action.MAIN"/>
 <category android:name="android.intent.category.LAUNCHER"/>
 </intent-filter>
 </activity>
 </application>
 </manifest> Android
  18. ը໘ͷߏ੒୯Ґ UIViewController Activity Fragment iOS Android

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

  20. ϥΠϑαΠΫϧ UIViewController init viewDidLoad viewWillAppear viewDidAppear viewWillDisappear viewDidDisappear deinit Activity

    onCreate onStart onRestoreInstanceState onResume onPause onSaveInstanceState onStop onDestroy iOS Android
  21. Activityͷ࠶ੜ੒ • Activity͸࠶ੜ੒͞ΕΔ • ը໘ͷճసͳͲͷมԽʹىҼ • ঢ়ଶΛࣦΘͳ͍Α͏ʹ࡞Δ • onSaveInstanceState •

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

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

  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
  25. Ϗϡʔ UIView View ViewGroup iOS Android

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

  27. ༷ʑͳϏϡʔ UIView View UILabel/UITextView TextView UITextField/UITextView EditText UIImageView ImageView UIButton

    Button/ImageButton UIScrollView ScrollView UITableView/UICollectionView RecyclerView UIWebView/WKWebView WebView iOS Android
  28. ϨΠΞ΢τϑΝΠϧ Storyboard Nib (Xib) Layout XML iOS Android

  29. Layout XML <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:orientation="vertical">
 <EditText
 android:id="@+id/user_name"
 android:layout_width="match_parent"


    android:layout_height="wrap_content"
 android:inputType="text"/>
 <EditText
 android:id="@+id/password"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:inputType="textPassword"/>
 <Button
 android:id="@+id/login_button"
 android:text="@string/action_sign_in"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"/>
 </LinearLayout> Android
  30. Ϗϡʔͱͷ઀ଓ Target Action @IBAction @IBOutlet android:id OnClickListener Data Binding iOS

    Android
  31. Data Binding Library <layout xmlns:android="http://schemas.android.com/apk/res/android">
 <data>
 <variable name="user" type="com.example.User"/>
 </data>


    <LinearLayout
 android:orientation="vertical"
 android:layout_width="match_parent"
 android:layout_height="match_parent">
 <TextView android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:text="@{user.firstName}"/>
 <TextView android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:text="@{user.lastName}"/>
 </LinearLayout>
 </layout> Android
  32. ϨΠΞ΢τͷํ๏ Auto Layout Resizing Mask ViewGroup iOS Android

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

  34. αΠζຖͷ࠷దԽ Size Class Display Scale User Interface Idiom ໋໊نଇ ը໘ີ౓

    ີ౓ඇґଘϐΫηϧ iOS Android
  35. Ϧιʔεͷ໋໊نଇ • res/layout/login.xml • σϑΥϧτ • res/layout-sw800dp/login.xml • ը໘෯͕800dpҎ্ •

    R.layout.login Android
  36. ը໘ີ౓ • xxxhdpi — 4.0 • xxhdpi — 3.0 •

    xhdpi — 2.0 • hdpi — 1.5 • mdpi — 1.0 • ldpi — 0.75 Android
  37. ୯Ґ • dp (ີ౓ඇґଘϐΫηϧ) • 160dpi • sp (εέʔϧඇґଘϐΫηϧ) •

    ઃఆ͞ΕͨςΩεταΠζʹൺྫ Android
  38. ༷ʑͳϦιʔε Asset Catalog Strings etc. Drawable R.drawable.ic_hamburger Values R.color.darkTextColor R.string.login

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

    Android
  40. Drawable • BitmapDrawable • RoundedBitmapDrawable • NinePatchDrawable • ShapeDrawable •

    VectorDrawable • AnimatedVectorDrawable • ColorDrawable • GradientDrawable • LayerDrawable • RippleDrawable • LevelListDrawable • StateListDrawable • AnimationDrawable • ClipDrawable • InsetDrawable • RotateDrawable • ScaleDrawable • PictureDrawable Android
  41. ϑΝΠϧΞΫηε NSFileManager Context iOS Android

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

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

  44. ετϨʔδ File System Core Data SQLite Keychain Internal Storage External

    Storage SQLite AccountManager Key Store iOS Android
  45. ݖݶ PHPhotoLibrary
 .requestAuthorization(_:) ύʔϛογϣϯ iOS Android

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

  47. ڞ༗ URL Scheme Open In Document Provider Extension Intent File

    System Content Provider iOS Android
  48. ςετ XCTest Unit Testing UI Testing Testing Support Library AndroidJUnitRunner

    Espresso UI Automator iOS Android
  49. iOS Android