Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
DroidKaigi2016 アプリを Xamarin に移植した話 #jxug
Search
amay077
May 07, 2016
Programming
1
4.4k
DroidKaigi2016 アプリを Xamarin に移植した話 #jxug
JXUGC #13 東京 緊急開催 Xamarin のすべて! -
http://jxug.connpass.com/event/29734/
の発表資料です。
amay077
May 07, 2016
Tweet
Share
More Decks by amay077
See All by amay077
愛知県新型コロナ対策サイト(非公式)の紹介
amay077
0
270
愛知県コロナ対策サイトが立ち上がってから
amay077
0
74
Xamarin.Forms Hot Reload のススメ
amay077
0
830
クロスプラットフォームモバイルアプリ開発ツール総ざらい2019 〜Titanium Mobile から Kotlin/Native まで〜 #droidkaigi
amay077
11
9.9k
ハムスター検出器を1日で作ってみた #NGK2018B
amay077
1
1k
App Center から Azure Pipeline に乗り換えた話
amay077
0
1.3k
Xamarin.Forms.GoogleMaps について
amay077
0
1.4k
Xamarin.Android で始めるクロスプラットフォームモバイルアプリ開発 #jaghama
amay077
0
610
Xamarin.Android で始めるクロスプラットフォームモバイルアプリ開発 #jxug
amay077
0
900
Other Decks in Programming
See All in Programming
Effective Signals in Angular 19+: Rules and Helpers @ngbe2024
manfredsteyer
PRO
0
140
Jakarta EE meets AI
ivargrimstad
0
260
StarlingMonkeyを触ってみた話 - 2024冬
syumai
3
270
menu基盤チームによるGoogle Cloudの活用事例~Application Integration, Cloud Tasks編~
yoshifumi_ishikura
0
110
快速入門可觀測性
blueswen
0
370
Amazon S3 NYJavaSIG 2024-12-12
sullis
0
100
【re:Growth 2024】 Aurora DSQL をちゃんと話します!
maroon1st
0
780
ある日突然あなたが管理しているサーバーにDDoSが来たらどうなるでしょう?知ってるようで何も知らなかったDDoS攻撃と対策 #phpcon.2024
akase244
1
140
Kaigi on Railsに初参加したら、その日にLT登壇が決定した件について
tama50505
0
100
見えないメモリを観測する: PHP 8.4 `pg_result_memory_size()` とSQL結果のメモリ管理
kentaroutakeda
0
390
Semantic Kernelのネイティブプラグインで知識拡張をしてみる
tomokusaba
0
180
コンテナをたくさん詰め込んだシステムとランタイムの変化
makihiro
1
140
Featured
See All Featured
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.3k
The Language of Interfaces
destraynor
154
24k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Testing 201, or: Great Expectations
jmmastey
40
7.1k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
Faster Mobile Websites
deanohume
305
30k
Visualization
eitanlees
146
15k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
Docker and Python
trallard
42
3.1k
How STYLIGHT went responsive
nonsquared
95
5.2k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
Transcript
DroidKaigi2016ΞϓϦΛ Xamarin ʹҠ২ͨ͠ ɹ ɹ ɹ ɹ - 2016/05/07 #JXUG
13 - @amay077 1 © @amay077 , 2016
ࣗݾհ • OKUYAMA Hironobu(@amay077) • Toyohashi, Aichi • Geospatial Engineer
• VB/VC('00-), C#('05-), Android/iOS('11-), Xamarin('13-) • BUILD Insider - XamarinٯҾ͖Tips 2 © @amay077 , 2016
DroidKaigi2016 ͷެࣜΞϓϦΛ Xamarin.Android Ҡ২ͨ͠ Λ͠·͢ • Android SDKͷബ͍ϥούʔ XamarinωΠςΟϒ ͷͰ͢
• Xamarin.Forms Ͱ͋Γ·ͤΜ • MVVM ͱ͔ɺiOSଞͱͷڞ௨Խͷ͠·ͤΜ • ࠷৽ͷ Android ΞϓϦ͕Ͳ͜·Ͱ Xamarin Ͱ։ൃՄೳ͔ʁ 3 © @amay077 , 2016
DroidKaigi2016 ͱ • droidkaigi.github.io • ΤϯδχΞ͕ओͷAndroidΧϯϑΝϨϯε • 2/18-19ɺ౦ژۀେֶ • ࢀՃऀ600ਓ(2Ͱച)ɺ45ηογϣϯ
ࠃAndroidΞϓϦ։ൃऀඞௌඞݟͷษڧձ 4 © @amay077 , 2016
DroidKaigi2016 ެࣜΞϓϦ ͱ • github.com/xamarinhq/app-evolve • εϐʔΧʔ/ελοϑͷ @konifar ͞Μ ͕ओಋ͠༗ࢤʢ
40໊ʂ ʣʹΑΓ։ൃ • ։ൃظؒɿ1/11ʙ2/12ʙ now • 6ը໘ɺ70Ϋϥεɺ4200ߦ(2/18࣌) Androidք۾ͷτοϓΤϯδχ Ξୡ͕࡞ͨ͠ݟͷմʂ 5 © @amay077 , 2016
AndroidΞϓϦΛ Xamarin.Android Ҡ২͢Δํ๏ • ը໘ • ॲཧ(Java) • ϥΠϒϥϦ
6 © @amay077 , 2016
ը໘ • ը໘ϨΠΞτɺը૾ɺจࣈྻϦιʔεͦͷ··ྲྀ༻Մೳ • activitymain.xml -> activitymain.axml • Android Data
Binding ͷ <layout> ͳͲɺ৽͍͠λάআ͕ඞཁ 7 © @amay077 , 2016
ࠨ:Java ӈ:Cˌ 8 © @amay077 , 2016
AndroidManifest.xml Xamarin.Android ʹ͓͍ͯɺը໘ͷ AndroidManifest.xml ͷఆ ٛෆཁ • <activity> ͷఆٛɺ XXXActivity
Ϋϥεͷଐੑ • <application> ͷఆٛɺ XXXApplication Ϋϥεͷଐੑ • ݖݶͷఆٛ AndroidManifest.xml ʹ͢Δ͕ Xamarin Studio/ Visual Studio ͷઃఆը໘͔Βߦ͑Δ 9 © @amay077 , 2016
// [BEFORE]AndroidManifest.xml in Java <application android:name=".MainApplication" android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme">
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="${mapsApiKey}" /> <activity android:name=".activity.MainActivity" android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation" 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.DEFAULT" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> 10 © @amay077 , 2016
// [AFTER]MainActivity.cs [Activity( ConfigurationChanges = ConfigChanges.Keyboard | ConfigChanges.KeyboardHidden | ConfigChanges.ScreenLayout
| ConfigChanges.ScreenSize | ConfigChanges.Orientation, Label = "@string/app_name", Theme = "@style/AppTheme.NoActionBar", MainLauncher = true)] [IntentFilter (new []{ Intent.ActionMain }, Categories = new []{ Intent.CategoryDefault })] public class MainActivity : AppCompatActivity { // ... } 11 © @amay077 , 2016
// [AFTER]MainApplication.cs [Android.App.Application( AllowBackup=true, Icon="@mipmap/ic_launcher", Theme="@style/AppTheme")] [MetaData("com.google.android.gms.version", Value = "@integer/google_play_services_version")]
[MetaData("com.google.android.maps.v2.API_KEY", Value = "{your google maps api key}")] public class MainApplication : Android.App.Application { // ... } 12 © @amay077 , 2016
ॲཧ • جຊతʹॻ͖͠ • ߏจࣅͯΔͷͰίϐϖͯ͠ΤϥʔΛফͯ͘͠ • Sharpen ͱ͍͏πʔϧ https:/ /blog.xamarin.com/android-in-c-
sharp/ ͋Δ͚ͲࠓͰ͑Δͷ͔ͳʁ • ໘ͩͬͨΒػೳ୯ҐͰ Jar Խͯ͠ɺBinding ܦ༝Ͱ༻ͨ͠ํ ͕Α͍͔ 13 © @amay077 , 2016
ϥΠϒϥϦ • Android ΞϓϦ։ൃʹ(ओʹΦʔϓϯιʔεͷ)ϥΠϒϥϦͷ༻ ෆՄܽ • Android StudioҎ߱ɺgradle ʹΑΓϥΠϒϥϦͷ༻ɾཧ͕ख ܰʹʢnugetΈ͍ͨͳΜʣ
DroidKaigiΞϓϦͰ 27 ͷϥΠϒϥϦΛ༻ Xamarin.AndroidԽʹ͓͚Δ Ұ൪ͷน 14 © @amay077 , 2016
ϥΠϒϥϦҠߦͷબࢶ 1. ಉػೳΛ࣋ͭ .NETͷϥΠϒϥϦ Λ୳͢ 2. ಉ໊ͷ BindingϥΠϒϥϦ Λ୳͢ 3.
ಉػೳΛ࣋ͭ BindingϥΠϒϥϦ Λ࡞Δ 4. ಉػೳΛ࣋ͭ .NETͷϥΠϒϥϦ Λ࡞Δ 5. ಉػೳΛ͖͋ΒΊΔ 15 © @amay077 , 2016
.NETͷϥΠϒϥϦ Λ୳͢ • Gson → JSON.NET • RxJava → Reactive
Extensions • Dagger2 → Stiletto • Retrofit2 → Refit ୳͢ͱ݁ߏ͋Δ twitter teratail, Stackoverflow.jp ͳͲͰฉ͍ͯΈΑ͏ حಛͳਓ͕୳ͯ͘͠ΕΔ͔͠Εͳ͍ ʛш´)ŧŽŕ 16 © @amay077 , 2016
ಉ໊ͷ BindingϥΠϒϥϦ Λ୳͢ • Android Support Library / Google Play
services • Picasso → Square.Picasso • AndroidFlowLayout → AndroidFlowLayout ɹ ஶ໊ͳϥΠϒϥϦͳΒطʹ XamarinରԠͷnugetύοέʔδ͕༻ҙ ͞Ε͍ͯΔʢಛʹViewؔ࿈Binding͔͠બࢶ͕ͳ͍ͷͰʣ Android Support Library ؔ࿈ҰඞͣϋϚΔͷͰམͪண͍ͯ 17 © @amay077 , 2016
BindingϥΠϒϥϦ Λ࡞Δ • gradle Ͱऔಘ͞ΕͨϥΠϒϥϦ͔Β xxx.jar Λൈ͖ग़͠ɺ Xamarin.Android ͷ BindingϓϩδΣΫτʹΈࠐΜͰϏϧυ͢Δ
18 © @amay077 , 2016
ಉػೳΛ࣋ͭ .NETͷϥΠϒϥϦ Λ࡞Δ • ཧܥ͚ͩͲ࠷ऴखஈ • جຊతͳػೳͳΒʢJSON.NET ͷΑ͏ʹʣطʹଘࡏ͢ΔͩΖ͏͠ • Binding
Θͳ͍ͱ͍͏͜ͱɺϚϧνϓϥοτϑΥʔϜΛҙ ࣝͯ͠ͷબͩΖ͏͠ɺқ૬ߴ͍ • ʮҠ২͚ͩʯͷ༧ࢉͰ͍͠ͱࢥ͏ • ClosedXML, EPPlus Έ͍ͨͳͷΛ Xamarin ରԠ͢Δͷχʔζ͋ Δͱࢥ͏ʢΓқߴ͍ʣ 19 © @amay077 , 2016
ಉػೳΛ͖͋ΒΊΔ ͝ར༻ܭըతʹ • Android-ORM - ORMϥΠϒϥϦ • ସϥΠϒϥϦͱͯ͠ SQLite.NET ORM
͕͋Δ͕ɺ͍ํ͕໘ ͩͬͨͷͰɺKey-Value ετΞͰ͋Δ Akavache Λ༻ • parceler - ը໘ؒ௨৴σʔλͷγϦΞϥΠζΛॿ͚ΔϥΠϒϥϦ • ସϥΠϒϥϦ͕ݟ͔ͭΒͳ͔ͬͨͷͰɺը໘ؒͷ௨৴σʔ λ JSON(JSON.NET) ʹͨ͠ 20 © @amay077 , 2016
Android DataBinding ʹ͍ͭͯ • Android Studio/gradle ͕ɺ<layout> ͰғΜͩൣғͷUIཁૉͷม Λࣗಈίʔυੜ •
͍ΘΏΔ MainForm.designer.cs తͳ • Xamarin.Android ͰະରԠͳͷͰ <layout> λά͕Τϥʔʹ • <layout> Λআ͠ɺಓʹ FindViewById ͨ͠ 21 © @amay077 , 2016
Ҡ২ͷ݁Ռ • github.com/amay077/DroidKaigi2016Xamarin • 2/11 - 2/23ʢਖ਼ຯ̒ؒ͘Β͍ʣ • ຊՈͷ։ൃεϐʔυ͕ૣ͗ͯ͢࠷৽ػೳͷ࣮·Ͱ͍͚ͭͣ •
buggy... Xamarin ͰϞμϯͳ AndroidΞϓϦ͕։ൃͰ͖ Δ͜ͱ͕֬ೝͰ͖ͨ 22 © @amay077 , 2016
·ͱΊ • ը໘ͱॲཧ • ྗٕͰҠ২Մೳ • ϥΠϒϥϦ • ཁ݅ʹԠͨ͡બ͕ඞཁ ͍ͣΕʹͯ͠
Android ΞϓϦ։ൃͷࣝඞਢ 23 © @amay077 , 2016
ͭ·ΓٻΊΒΕΔͷ… 24 © @amay077 , 2016
εʔύʔXamarinਓࡐʂ 25 © @amay077 , 2016
26 © @amay077 , 2016
ʲ͓·͚ʳ͞·͟·ͳΧϯϑΝϨϯεΞϓϦ 27 © @amay077 , 2016
Google I/O 2015 App • github.com/google/iosched • Android ͷΈରԠ •
I/O 2016 App ͦͷ͏ͪ͘Δʁ 28 © @amay077 , 2016
try! Swift App • github.com/tryswift/trySwiftApp • iOS ͷΈରԠ • 3/2-4
ʹ։࠵͞ΕͨiOS/Swiftσϕϩο ύʔ͚ΠϕϯτͷެࣜΞϓϦ 29 © @amay077 , 2016
Xamarin Evolve 2016 App • github.com/xamarinhq/app-evolve • Android / iOS/
Windows ରԠɺ࠷ڧײ͋Δ 30 © @amay077 , 2016