Download - NET? MonoDroid Does
![Page 1: NET? MonoDroid Does](https://reader034.vdocuments.us/reader034/viewer/2022051323/54b7a47d4a79592d048b4667/html5/thumbnails/1.jpg)
.NET? Mono for Android Does
Kevin McMahon
@klmcmahon
http://blog.kevfoo.com
![Page 2: NET? MonoDroid Does](https://reader034.vdocuments.us/reader034/viewer/2022051323/54b7a47d4a79592d048b4667/html5/thumbnails/2.jpg)
Overview
• Overview of Android
• Mono for Android : What, How, Why
• Code Demo
• Mono for Android Resources
![Page 3: NET? MonoDroid Does](https://reader034.vdocuments.us/reader034/viewer/2022051323/54b7a47d4a79592d048b4667/html5/thumbnails/3.jpg)
What is Android?
• Application Framework
• Dalvik Virtual Machine
• Optimized OpenGL ES 1.0 graphics library
• Customized Linux 2.6 kernel
• Rich development environment
![Page 4: NET? MonoDroid Does](https://reader034.vdocuments.us/reader034/viewer/2022051323/54b7a47d4a79592d048b4667/html5/thumbnails/4.jpg)
Android Stack
![Page 5: NET? MonoDroid Does](https://reader034.vdocuments.us/reader034/viewer/2022051323/54b7a47d4a79592d048b4667/html5/thumbnails/5.jpg)
Android Stack
![Page 6: NET? MonoDroid Does](https://reader034.vdocuments.us/reader034/viewer/2022051323/54b7a47d4a79592d048b4667/html5/thumbnails/6.jpg)
Android Stack
![Page 7: NET? MonoDroid Does](https://reader034.vdocuments.us/reader034/viewer/2022051323/54b7a47d4a79592d048b4667/html5/thumbnails/7.jpg)
Android Stack
![Page 8: NET? MonoDroid Does](https://reader034.vdocuments.us/reader034/viewer/2022051323/54b7a47d4a79592d048b4667/html5/thumbnails/8.jpg)
Android Stack
![Page 9: NET? MonoDroid Does](https://reader034.vdocuments.us/reader034/viewer/2022051323/54b7a47d4a79592d048b4667/html5/thumbnails/9.jpg)
Dalvik Virtual Machine
• Dalvik Virtual Machine– Register-based– Runs multiple VMs efficiently– Requires a .class to .dex transformation– JIT (as of Android 2.2)
• Each Android Application:– Runs in their own process – Runs on their own VM
![Page 10: NET? MonoDroid Does](https://reader034.vdocuments.us/reader034/viewer/2022051323/54b7a47d4a79592d048b4667/html5/thumbnails/10.jpg)
What is Mono for Android?
• Commercial Product from Novell– $399 individual / ~$999 enterprise / ~$99 student
• Windows and Mac OS X (Linux soon)• Open preview– DOWNLOAD AND TRY IT!
• Project is getting really close to 1.0– No “Go Live” license yet– Not done with optimizations– Still changing the API
![Page 11: NET? MonoDroid Does](https://reader034.vdocuments.us/reader034/viewer/2022051323/54b7a47d4a79592d048b4667/html5/thumbnails/11.jpg)
How Does it Work?
• Mono Runtime– Native to the device– Executes .Net code– Runs side-by-side with Dalvik
• Mono to Android Communication– Java proxies• Android Callable Wrappers • Managed Callable Wrappers
![Page 12: NET? MonoDroid Does](https://reader034.vdocuments.us/reader034/viewer/2022051323/54b7a47d4a79592d048b4667/html5/thumbnails/12.jpg)
Mono for Android Architecture
![Page 13: NET? MonoDroid Does](https://reader034.vdocuments.us/reader034/viewer/2022051323/54b7a47d4a79592d048b4667/html5/thumbnails/13.jpg)
Mono for Android Design Principles
• Follow the Framework Design Guidelines
• Allow developers to subclass any Java class
• C# delegates (lambdas, anonymous methods)
• Java properties as C# properties
• Strongly typed API
![Page 14: NET? MonoDroid Does](https://reader034.vdocuments.us/reader034/viewer/2022051323/54b7a47d4a79592d048b4667/html5/thumbnails/14.jpg)
Why use Mono for Android?
• Mono for Android story not as compelling as MonoTouch.– GC, decent IDE, not Objective-C
• Opportunities for re-use across platforms– iOS, Android, Windows Phone 7 non-UI components– MonoGame which is a port of XNA
• Development tooling and environment– Visual Studio– MonoDevelop
• C# > Java– Friction still due to Java idioms and architecture.
![Page 15: NET? MonoDroid Does](https://reader034.vdocuments.us/reader034/viewer/2022051323/54b7a47d4a79592d048b4667/html5/thumbnails/15.jpg)
Deployment Options
• Deploy to Android Virtual Device
• Deploy to Device
• Debug capabilities on both
• Sell (eventually)
– Android Marketplace
– Amazon App Store
![Page 16: NET? MonoDroid Does](https://reader034.vdocuments.us/reader034/viewer/2022051323/54b7a47d4a79592d048b4667/html5/thumbnails/16.jpg)
Android Application Concepts
• Activities
• Services
• Content Providers
• Intents
• Resources
![Page 17: NET? MonoDroid Does](https://reader034.vdocuments.us/reader034/viewer/2022051323/54b7a47d4a79592d048b4667/html5/thumbnails/17.jpg)
Activities
• Orchestrates a UI view• Applications are composed of 1-to-Many
activities
• One activity marked as main and shown first upon launch
![Page 18: NET? MonoDroid Does](https://reader034.vdocuments.us/reader034/viewer/2022051323/54b7a47d4a79592d048b4667/html5/thumbnails/18.jpg)
Activities - Views
• Each activity is given a default window to draw in.
• Content of the window is provided by a hierarchy of views
• A view hierarchy is placed within an activity's window by the Activity.SetContentView()
![Page 19: NET? MonoDroid Does](https://reader034.vdocuments.us/reader034/viewer/2022051323/54b7a47d4a79592d048b4667/html5/thumbnails/19.jpg)
Activity Life Cycle
• onCreate• onStart• onResume• onPause• onStop• onDestroy
![Page 20: NET? MonoDroid Does](https://reader034.vdocuments.us/reader034/viewer/2022051323/54b7a47d4a79592d048b4667/html5/thumbnails/20.jpg)
Services
• Android service are what you’d expect.• Possible to bind to an ongoing service and
communicate via exposed interface• Runs in main application process but doesn’t
block other components or UI
![Page 21: NET? MonoDroid Does](https://reader034.vdocuments.us/reader034/viewer/2022051323/54b7a47d4a79592d048b4667/html5/thumbnails/21.jpg)
Content Providers
• Queryable application data stores• Only way to share data amongst other apps• Android ships with common providers– Audio, video, images, contacts, etc.
• Making your application’s data public– Create a new provider– Add your data to existing provider
![Page 22: NET? MonoDroid Does](https://reader034.vdocuments.us/reader034/viewer/2022051323/54b7a47d4a79592d048b4667/html5/thumbnails/22.jpg)
Content Provider Layer
Applications
Content Providers
Contacts Music Video
sPictur
es …
![Page 23: NET? MonoDroid Does](https://reader034.vdocuments.us/reader034/viewer/2022051323/54b7a47d4a79592d048b4667/html5/thumbnails/23.jpg)
Intents
• Eventing mechanism• Intent objects are passive data that is of
interest to the component that is receiving the intent
• Filterable
![Page 24: NET? MonoDroid Does](https://reader034.vdocuments.us/reader034/viewer/2022051323/54b7a47d4a79592d048b4667/html5/thumbnails/24.jpg)
Resources
• Images, layout descriptions, binary blobs and string
dictionaries
• Abstraction layer which helps decouples code
• Makes managing assets easier
– Localization
– Multiple displays
– Different hardware configurations
![Page 26: NET? MonoDroid Does](https://reader034.vdocuments.us/reader034/viewer/2022051323/54b7a47d4a79592d048b4667/html5/thumbnails/26.jpg)
Mono for Android Resources
Download the Preview!• http://mono-android.net/Welcome
Links• http://www.mono-android.net• http://developer.android.com/
IRC Support / Discussion• #monodroid on irc.gnome.org
Code• https://github.com/mono/monodroid-samples• https://github.com/kevinmcmahon/MonoDroid101