65
Mobile Híbrido Loiane Groner http://loiane.com @loiane

MNT2014: Mobile Hibrido com Phonegap

Embed Size (px)

DESCRIPTION

Palestra apresentada no dia 29 de março de 2014 no 2 encontro das mulheres na tecnologia, em Goiânia - GO.

Citation preview

Page 1: MNT2014: Mobile Hibrido com Phonegap

Mobile HíbridoLoiane Groner

http://loiane.com @loiane

Page 2: MNT2014: Mobile Hibrido com Phonegap

Me, Myself && I

!

•Gerente de Desenv Projetos

•8+ XP TI

•Java JUG Leader

•Sencha Community Leader

•http://loiane.com

•@loiane

Page 3: MNT2014: Mobile Hibrido com Phonegap

packpub.com ou amazon.com

Page 4: MNT2014: Mobile Hibrido com Phonegap
Page 5: MNT2014: Mobile Hibrido com Phonegap
Page 6: MNT2014: Mobile Hibrido com Phonegap
Page 7: MNT2014: Mobile Hibrido com Phonegap

Android

iOS

Windows Phone

Page 8: MNT2014: Mobile Hibrido com Phonegap

Android

iOS

Windows Phone

• Java • Eclipse (qualquer OS)

100

Page 9: MNT2014: Mobile Hibrido com Phonegap

Android

iOS

Windows Phone

• Java • Eclipse (qualquer OS)

100

• Objective C • Xcode + Mac OS 100

Page 10: MNT2014: Mobile Hibrido com Phonegap

Android

iOS

Windows Phone

• Java • Eclipse (qualquer OS)

100

• Objective C • Xcode + Mac OS 100

• C#/XAML • Visual Studio + Windows 100

Page 11: MNT2014: Mobile Hibrido com Phonegap

Android

iOS

Windows Phone

• Java • Eclipse (qualquer OS)

100

• Objective C • Xcode + Mac OS 100

• C#/XAML • Visual Studio + Windows 100

300

Dev

Mant

Page 12: MNT2014: Mobile Hibrido com Phonegap

CSS

HTMLJavascript

Desenvolvimento Híbrido Mobile

Page 13: MNT2014: Mobile Hibrido com Phonegap

CSS

HTMLJavascript

Desenvolvimento Híbrido Mobile

Page 14: MNT2014: Mobile Hibrido com Phonegap

CSS

HTMLJavascript

Desenvolvimento Híbrido Mobile

Windows Phone

IOS Android

Plataformas diferentes como target

Page 15: MNT2014: Mobile Hibrido com Phonegap
Page 16: MNT2014: Mobile Hibrido com Phonegap

CSS

HTMLJavascript

100

Page 17: MNT2014: Mobile Hibrido com Phonegap

CSS

HTMLJavascript

100

BuildWindows

Phone

IOS

Android5

5

5

Page 18: MNT2014: Mobile Hibrido com Phonegap

CSS

HTMLJavascript

100

BuildWindows

Phone

IOS

Android5

5

5

115

Page 19: MNT2014: Mobile Hibrido com Phonegap

PhoneGap

Page 20: MNT2014: Mobile Hibrido com Phonegap

Acesso Nativo ao Device usando

apenas JavaScript.

“ http://phonegap.com/

Page 21: MNT2014: Mobile Hibrido com Phonegap

App Nativa

Dispositivo

App Híbrida

executa UI e

(alguma) lógica de

negócio

Código Nativo

Interpretador

JavaScript

Ponte

Page 22: MNT2014: Mobile Hibrido com Phonegap

App Nativa

Dispositivo

App Híbrida

executa UI e

(alguma) lógica de

negócio

Código Nativo

Interpretador

JavaScript

Ponte

Web Server

Java/PHP/Ruby/C#

Arquivos Imagens/

Documentos

Banco de Dados

Backend

http://

Lógica de negócio

http://

Page 23: MNT2014: Mobile Hibrido com Phonegap

Desenvolvimento de App Híbrida

Page 24: MNT2014: Mobile Hibrido com Phonegap

Desenvolvimento de App Híbrida

Passo 1: Criar app com HTML/JS/CSS

Page 25: MNT2014: Mobile Hibrido com Phonegap

Desenvolvimento de App Híbrida

Passo 1: Criar app com HTML/JS/CSS

Passo 2: Criar projeto usando API Phonegap e caso seja necessário usar API para acesso nativo

Page 26: MNT2014: Mobile Hibrido com Phonegap

Desenvolvimento de App Híbrida

Passo 1: Criar app com HTML/JS/CSS

Passo 2: Criar projeto usando API Phonegap e caso seja necessário usar API para acesso nativo

Passo 3: Fazer Build e empacotar app

Page 27: MNT2014: Mobile Hibrido com Phonegap

Desenvolvimento de App Híbrida

Passo 1: Criar app com HTML/JS/CSS

Passo 2: Criar projeto usando API Phonegap e caso seja necessário usar API para acesso nativo

Passo 3: Fazer Build e empacotar app

Passo 4: Enviar para App Store, Google Play, Market Place, etc

Page 28: MNT2014: Mobile Hibrido com Phonegap
Page 29: MNT2014: Mobile Hibrido com Phonegap

Phonegap não converte em código

nativo

Page 30: MNT2014: Mobile Hibrido com Phonegap

import android.app.Activity;!import android.content.Intent;!import android.graphics.Bitmap;!import android.os.Bundle;!import android.view.View;!import android.widget.Button;!import android.widget.ImageView;!!public class MyCameraActivity extends Activity {! private static final int CAMERA_REQUEST = 1888; ! private ImageView imageView;!! @Override! public void onCreate(Bundle savedInstanceState) {! super.onCreate(savedInstanceState);! setContentView(R.layout.main);! this.imageView = (ImageView)this.findViewById(R.id.imageView1);! Button photoButton = (Button) this.findViewById(R.id.button1);! photoButton.setOnClickListener(new View.OnClickListener() {!! @Override! public void onClick(View v) {! Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); ! startActivityForResult(cameraIntent, CAMERA_REQUEST); ! }! });! }!! protected void onActivityResult(int requestCode, int resultCode, Intent data) { ! if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) { ! Bitmap photo = (Bitmap) data.getExtras().get("data"); ! imageView.setImageBitmap(photo);! } ! } !}!

Page 31: MNT2014: Mobile Hibrido com Phonegap

- (BOOL) startCameraControllerFromViewController: (UIViewController*) controller! usingDelegate: (id <UIImagePickerControllerDelegate,! UINavigationControllerDelegate>) delegate {! ! if (([UIImagePickerController isSourceTypeAvailable:! UIImagePickerControllerSourceTypeCamera] == NO)! || (delegate == nil)! || (controller == nil))! return NO;! ! ! UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];! cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera;! ! // Displays a control that allows the user to choose picture or! // movie capture, if both are available:! cameraUI.mediaTypes =! [UIImagePickerController availableMediaTypesForSourceType:! UIImagePickerControllerSourceTypeCamera];! ! // Hides the controls for moving & scaling pictures, or for! // trimming movies. To instead show the controls, use YES.! cameraUI.allowsEditing = NO;! ! cameraUI.delegate = delegate;! ! [controller presentModalViewController: cameraUI animated: YES];! return YES;!}!

Page 32: MNT2014: Mobile Hibrido com Phonegap

// Check to see if the camera is available on the device.!if (PhotoCaptureDevice.AvailableSensorLocations.Contains(CameraSensorLocation.Back) ||! PhotoCaptureDevice.AvailableSensorLocations.Contains(CameraSensorLocation.Front))!{! // Initialize the camera, when available.! if (PhotoCaptureDevice.AvailableSensorLocations.Contains(CameraSensorLocation.Back))! {! // Use the back camera.! System.Collections.Generic.IReadOnlyList<Windows.Foundation.Size> SupportedResolutions = ! PhotoCaptureDevice.GetAvailableCaptureResolutions(CameraSensorLocation.Back);! Windows.Foundation.Size res = SupportedResolutions[0];! this.captureDevice = await PhotoCaptureDevice.OpenAsync(CameraSensorLocation.Back, res);! }! else! {! // Otherwise, use the front camera.! System.Collections.Generic.IReadOnlyList<Windows.Foundation.Size> SupportedResolutions = ! PhotoCaptureDevice.GetAvailableCaptureResolutions(CameraSensorLocation.Front);! Windows.Foundation.Size res = SupportedResolutions[0];! this.captureDevice = await PhotoCaptureDevice.OpenAsync(CameraSensorLocation.Front, res);! }! ...! ...! ...!! //Set the VideoBrush source to the camera.! viewfinderBrush.SetSource(this.captureDevice);!! // The event is fired when the shutter button receives a half press.! CameraButtons.ShutterKeyHalfPressed += OnButtonHalfPress;!! // The event is fired when the shutter button receives a full press.! CameraButtons.ShutterKeyPressed += OnButtonFullPress;!! // The event is fired when the shutter button is released.! CameraButtons.ShutterKeyReleased += OnButtonRelease; }!else!{! // The camera is not available.! this.Dispatcher.BeginInvoke(delegate()! {! // Write message.! txtDebug.Text = "A Camera is not available on this phone.";! });!}!

Page 33: MNT2014: Mobile Hibrido com Phonegap

function capturePicture(){!! navigator.camera.getPicture( cameraSuccess, cameraError, {!! ! quality: 50,!! ! destinationType: destinationType.DATA_URL!! } );!}!

Page 34: MNT2014: Mobile Hibrido com Phonegap

Phonegap não tem componente, não se integra com server

(php, java)

Page 35: MNT2014: Mobile Hibrido com Phonegap
Page 36: MNT2014: Mobile Hibrido com Phonegap

joApp

Wink Toolkit

Page 37: MNT2014: Mobile Hibrido com Phonegap

Phonegap não gera projeto web, gera

projeto nativo que faz uso da API do

phonegap

Page 38: MNT2014: Mobile Hibrido com Phonegap
Page 39: MNT2014: Mobile Hibrido com Phonegap
Page 40: MNT2014: Mobile Hibrido com Phonegap

Processo de build e processo de enviar para apps store é

nativo

Page 41: MNT2014: Mobile Hibrido com Phonegap

Desenvolva

Teste

Build

Desenvolva

Teste

Build

Page 42: MNT2014: Mobile Hibrido com Phonegap

Desenvolva

Teste

Build

Desenvolva

Teste

Build

Desenvolva

Teste

Build Build

{Híbrido

Page 43: MNT2014: Mobile Hibrido com Phonegap
Page 44: MNT2014: Mobile Hibrido com Phonegap
Page 45: MNT2014: Mobile Hibrido com Phonegap

Não serve para qualquer app

Page 46: MNT2014: Mobile Hibrido com Phonegap

Demo

Page 47: MNT2014: Mobile Hibrido com Phonegap

http://www.sencha.com/apps/

http://phonegap.com/app/

Page 48: MNT2014: Mobile Hibrido com Phonegap

http://phonegap.com/app/fruit-salad/

Page 49: MNT2014: Mobile Hibrido com Phonegap
Page 50: MNT2014: Mobile Hibrido com Phonegap

1

Page 51: MNT2014: Mobile Hibrido com Phonegap
Page 52: MNT2014: Mobile Hibrido com Phonegap
Page 53: MNT2014: Mobile Hibrido com Phonegap
Page 54: MNT2014: Mobile Hibrido com Phonegap
Page 55: MNT2014: Mobile Hibrido com Phonegap
Page 56: MNT2014: Mobile Hibrido com Phonegap
Page 57: MNT2014: Mobile Hibrido com Phonegap
Page 58: MNT2014: Mobile Hibrido com Phonegap

2

Page 59: MNT2014: Mobile Hibrido com Phonegap

3

Page 60: MNT2014: Mobile Hibrido com Phonegap
Page 61: MNT2014: Mobile Hibrido com Phonegap

4

Page 62: MNT2014: Mobile Hibrido com Phonegap
Page 63: MNT2014: Mobile Hibrido com Phonegap
Page 64: MNT2014: Mobile Hibrido com Phonegap

http://loiane.com

facebook.com/loianegroner

@loiane

https://github.com/loiane

youtube.com/user/Loianeg

Page 65: MNT2014: Mobile Hibrido com Phonegap

Loiane Groner loiane.com