Workshop - Szkolenie Xamarin Android

Post on 11-Jun-2015

283 views 5 download

description

Szkolenie

Transcript of Workshop - Szkolenie Xamarin Android

Reklama

Reklama

O Mnie • Nazywam się Andrzej Piotrowski aka Sir Anen

• Jestem po Rolnictwie – Kadży orze jak Może

• Pracowałem dla Credit Swiss, Viessmann R&D czy IBM’ie + Agencje Kreatwyne – Wrocław

• Przeprowadze dla was wstęp techniczny

• Czemu nikt mi za to nie płaci

• Wiem że Umiem – Ty też to Umiesz (siła woli)

• Zaczynamy przygode – pytanie to ręka w górę

Agenda• Xamarin – Z czym sie to wiąże w Mobile

• Android – Jak wygląda praca z Nim

• Android Design Patterns – Budujemy z głową i dla ludzi a nie dla własnego dobra (community)

• Google Play – Jak to wygląda od strony Dev

• Xamarin Android Aplikacja - Przygoda

• Zadanie domowe - Rozdzielenie

• Ustalenie współpracy ze mną

XAMARIN?

“The best damn mobile team,building the best damn mobile platform.”

MY TEŻ TAK MOŻEMY

Mono?• Mono 1.0 was released on June 30, 2004

• “The Mono runtime contains a code execution engine that translates ECMA CIL byte codes into native code and supports a number of processors: ARM, MIPS SPARC, PowerPC, S390 , x86, x86-64 and IA-64 for 64-bit modes.”

• Runs on Linux, OSX, Windows, PS3, XBox 360, Wii

•Windows Phone 7 i 8 + Android + iOS

Jak działa Mono?Pamiętajmy o certyfikacji :

Apple ma duże restrykcje

Pamiętajmy o certyfikacji : Google ma

duże możliwości

Pamiętajmy o certyfikacji : Windows ma duże pretensje że wógle coś wrzucasz na Sklep

Struktura - CorePiszemy tylko kod (core code) RAZ, możemy

skupić na dopasowawniu do UI danego systemu operacyjnego.

xamarin.mobileKomponent dla wykorzystania do loklaizacji, zdjec

czy dostepu do kontaktow dla wszystkich platform.

xamarin.SocialKomponent dla wykorzystania do App.Net, Twitter,

Facebook, and Flickr

xamarin.authKomponent dla wykorzystania do OAuth.

DataRestSharp, SQLite.NET, and JSON.net to nie które rzeczy które programista wykorzystuje w pracy.

Komponenty Androida czyli jak żyć na Google

PlayOmówienie zasad projektowania od zera javy

do .net codera. Android to jakieś 11000 urządzeń do wsparcia.

Obecnie jest wersja APK 19 – my piszemy od APK 11.

Linux Kernel

Application Framework

Applications

LibrariesAndroid Runtime

Linux Kernel

• Work as HAL (Hardware Abstraction Layer)

• Device Drivers

• memory management

• Process Management

• Networking

Libraries

• C/C++ Libraries

• Interface through Java

• Handling User Interface

• 2D/3D Graphics

• Media Acces, Browser Engine, SQLite

Android Runtime

• Dalvik Virtual machine

• .dex file

• Compact and Efficient

• Limited memory & Power

• .java -> .class -> .jar -> .dex

• Core Libraries

• Java Standard Edition

Application Framework

• API Interface

• Activity manager

• Content Providers

• Location Manager etc

Applications

• Built in and User application

• Can install using .apk files

• Example: Phone Dialer, WeChat, Web Browser, Hello Android or others

Architecture of Android

Android SDK

Android Application Life Cycle

Starting

Running

Stopped Paused

Destroyed

onCreate()onStart()

onSaveInstanceState()onPause()

onDestroy()onDestroy()

onRestart()onStart()

onResume()

onSaveInstanceState()onStop()

onResume()

iOS (iPhone) Android OS

One version for all devices Customized System by Manufacturer

Operation System (Graphic Design)

Fol

ie 1

8

Design Patterns

iOS (iPhone) Android OS

Application Hardware/Application

1 System Button 3-4 System Buttons

Navigation

Fol

ie 1

9

Design Patterns

iOS (iPhone) Android OS

Software HardwareSystem feature – 4 Buttons

Navigation - Back Button

Fol

ie 2

0

iOS (iPhone) Android OS

3 Devices 1000+ Devices

2 Display resolutions/sizes Different screen sizes (3,7’ – 10,1’) Different resolutions

Display Size/Resolution

Fol

ie 2

1

iPhone iPod iPad

Android SDK emulator ->

<- Genymotion emulator

What’s inside an App ?

Drawable Layouts Values Assets

Android Manifest

Default Activity

Content

Service

LibrariesDefault Activity

Default Activity

Other Activities

Android Application

Anatomia Xamarin Android app

Android Manifest.xml

Edit App Name & Package, Icon, Version #, Min and Target Android SDKs, Permissions

specify supported screens

http://developer.android.com/guide/topics/manifest/supports-screens-element.html

Pro tip: need for speed

You can specify hardware acceleration for the app or for specific activities.

http://developer.android.com/guide/topics/graphics/hardware-accel.html

More activity options

http://developer.android.com/guide/topics/manifest/activity-element.html

Activities

Activity Lifecycle

lifecycle in use

another example

OnResume and OnPause are good placesto do assignment and release.

declaring activity behavior

In this case, InitialActivity is our splash/loading screen.

layouts

Anatomy of a layout

includes

layouts for orientations

By creating a directory “layout-land,” Activities will use this as content when orientation changes.http://docs.xamarin.com/guides/android/application_fundamentals/handling_rotation/

layouts for screen sizes

“layout-large” is for Android apps below API-13, “layout-swXXXdp” is for 13 and above.

How layouts are connected to your code

Strings.xml

How to connect strings.xml to your code

You can link via layout xml or use “GetString” from your

Activity.

string array

This can be used as a data provider for a spinner.

Style.xml

declare reusable styles

Units of measure

pxPixels - corresponds to actual pixels on the screen.

inInches - based on the physical size of the screen.

mmMillimeters - based on the physical size of the screen.

ptPoints - 1/72 of an inch based on the physical size of the screen.

dpDensity-independent Pixels - an abstract unit that is based on the physical density of the screen. These units are relative to a 160 dpi screen

Connect style to view

Drawables

Using a PNG

PNGS FOR STATES

vector drawable

alternative drawables

Using folder naming conventions will tellAndroid what version of the drawable to use

MainApplication

sending intents

receiving intents

Create and assign adapter

FragmentsAndroid 3.0+

Set layout of Activity

init tab fragments

the fragment

fragment lifecycle

Fragments are important

Fragments promote code reuse.

custom views

Month Layout

Week Layout

notated cell

OnDraw

UpdateSwatches

Calendar month activity

Update calendar

Update week labels

when month events set

Updating cell swatches

Podsumowanie

- Android SDK w Xamarinie nie jest specialnie trudny ale trzeba mieć background z aplikacjami – dobrze znać ADB.

- Ilość urządzeń do przetestowania – o matko- ale da się dzięki usługą (TestCloud) czy (TestDroid)

- Emulatory są do bani. Testować na urządzeniu bo nakładki.

- Planować z głową swoj LayoutUX/Design

Zadanie Domowe