100
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 1

1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 1

Page 2: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 2

Integrating Device Services with ADF Mobile

Page 3: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 3

Apache Cordova / PhoneGap

ADF Mobile utilizes PhoneGap to access most of the onboard devices

services

– To be replaced by Apache Cordova soon

Provides access to:

– Device Properties

– SMS and Email (Not through PhoneGap)

– Contacts

– Camera and Photo Library

– Geolocation

Page 4: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 4

Overview Accessing Device Services

2. Implicit EL Objects

3. Programmatic APIs

1. Data Controls

Page 5: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 5

Overview Accessing Device Services

2. Implicit EL Objects

3. Programmatic APIs

1. Data Controls

Found in the Data Control Palette

Drag n drop services onto a page

Take the grunt work out of coding

calls to the API and constructing

the necessary screens

Page 6: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 6

Overview Accessing Device Services

2. Implicit EL Objects

3. Programmatic APIs

1. Data Controls

Provide easy access to device

properties

Referenced via the UI components

Simply type or use the Expression

Builder

#{deviceScope.device.hasContacts}

Page 7: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 7

Overview Accessing Device Services

2. Implicit EL Objects

3. Programmatic APIs

1. Data Controls

Provide programmers the flexibility of accessing device services

from Java with their own Java Beans

Easier to handle error conditions and process any outputs

DeviceManager dm = DeviceManagerFactory.getDeviceManager();

dm.sendEmail("[email protected]","[email protected]",

"Test email", "Test message", null, null, null);

Page 8: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 8

Device Service Accessible from JavaScript

Access device services from non AMX pages

– Remote URL

– Local HTML

Add JavaScript library to your page

Direct access to invoke device features

Use adf.mf.api.*

– adf.mf.api.sendSMS({to: "5551234567", body: "This is a test message"});

Page 9: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 9

Page 10: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 10

Accessing Device Properties

Service Data Control EL Access Programmatic

Device Properties Yes Yes

Page 11: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 11

Property Static/Dyna

mic EL Expression Sample Value Java API

device.name Static #{deviceScope.device.name} "Joe Smith's iPhone" DeviceManager.getName()

device.platform Static #{deviceScope.device.platform} "iPhone" DeviceManager.getPlatform()

device.version Static #{deviceScope.device.version} "4.3.2", "5.0.1" DeviceManager.getVersion()

device.os Static #{deviceScope.device.os} "iOS" DeviceManager.getOs()

device.model Static #{deviceScope.device.model} "i386", "iPhone3,1" DeviceManager.getModel()

device.phonegap Static #{deviceScope.device.phonegap} "1.0.0" DeviceManager.getPhonegap()

hardware.hasCamera Static #{deviceScope.hardware.hasCamera} true, false DeviceManager.hasCamera()

hardware.hasContacts Static #{deviceScope.hardware.hasContacts} true, false DeviceManager.hasContacts()

hardware.hasTouchScreen Static #{deviceScope.hardware.hasTouchScreen} true, false DeviceManager.hasTouchScreen()

hardware.hasGeolocation Static #{deviceScope.hardware.hasGeolocation} true, false DeviceManager.hasGeolocation()

hardware.hasAccelerometer Static #{deviceScope.hardware.hasAccelerometer} true, false DeviceManager.hasAccelerometer()

hardware.hasCompass Static #{deviceScope.hardware.hasCompass} true, false DeviceManager.hasCompass()

hardware.hasFileAccess Static #{deviceScope.hardware.hasFileAccess} true, false DeviceManager.hasFileAccess()

hardware.hasLocalStorage Static #{deviceScope.hardware.hasLocalStorage} true, false DeviceManager.hasLocalStorage()

hardware.hasMediaPlayer Static #{deviceScope.hardware.hasMediaPlayer} true, false DeviceManager.hasMediaPlayer()

hardware.hasMediaRecorder Static #{deviceScope.hardware.hasMediaRecorder} true, false DeviceManager.hasMediaRecorder()

hardware.networkStatus Dynamic #{deviceScope.hardware.networkStatus} "wifi","2g","unknown" DeviceManager.getNetworkStatus()

hardware.screen.width Dynamic #{deviceScope.hardware.screen.width} 320, 480 DeviceManager.getScreenWidth()

hardware.screen.height Dynamic #{deviceScope.hardware.screen.height} 480, 320 DeviceManager.getScreenHeight()

hardware.availableWidth Dynamic #{deviceScope.hardware.availableWidth} <= 320, <= 480 DeviceManager.getAvailableScreenWidth()

hardware.availableHeight Dynamic #{deviceScope.hardware.availableHeight} <= 480, <= 320 DeviceManager.getAvailableScreenHeight()

hardware.screen.dpi Static #{deviceScope.hardware.screen.dpi} 160, 326 DeviceManager.getScreenDpi()

hardware.screen.diagonalSize Static #{deviceScope.hardware.screen.diagonalSize} 9.7, 6.78 DeviceManager.getScreenDiagonalSize()

hardware.screen.scaleFactor Static #{deviceScope.hardware.screen.scaleFactor} 1.0, 2.0 DeviceManager.getScreenScaleFactor()

Page 12: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 12

PRODUCT DEMONSTRATION ACCESSING DEVICE PROPERTIES via EL Expression

Page 13: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 13

Page 14: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 14

Page 15: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 15

Page 16: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 16

Page 17: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 17

PRODUCT DEMONSTRATION ACCESSING DEVICE PROPERTIES via a Java Bean

Page 18: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 18

01 public class MyBean {

02

03 // Called via a button

04 public void actionSendSms(ActionEvent event) {

05 DeviceManager device = DeviceManagerFactory.getDeviceManager();

06

07 boolean hasCamera = device.hasCamera();

08 }

Device Properties API Example

Page 19: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 19

Accessing Device Properties

Service Data Control EL Access Programmatic

Device Properties Yes Yes

Send SMS Yes Yes

Page 20: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 20

PRODUCT DEMONSTRATION SENDING SMS via the Data Control

Page 21: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 21

Page 22: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 22

Page 23: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 23

Page 24: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 24

Page 25: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 25

Page 26: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 26

Page 27: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 27

PRODUCT DEMONSTRATION SENDING SMS via a Java Bean

Page 28: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 28

01 public class oracle.adf.model.datacontrols.device.DeviceManager {

02

03 /**

04 * Display the operating system's default UI for sending a text

05 * message, and optionally pre-populate certain fields

06 *

07 * @param to - recipient list (comma-separated)

08 * @param body - text of message

09 */

10 public void sendSMS(java.lang.String to, java.lang.String body)

Send SMS API

Page 29: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 29

01 public class MyBean {

02

03 // Called via a button

04 public void actionSendSms(ActionEvent event) {

05 DeviceManager device = DeviceManagerFactory.getDeviceManager();

06

07 String to = "11112222,33334444";

08 String body = "A test SMS";

09

10 device.sendSms(to, body);

11 }

12 }

Send SMS API Example

Page 30: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 30

Page 31: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 31

Page 32: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 32

Page 33: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 33

Page 34: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 34

Page 35: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 35

Page 36: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 36

Page 37: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 37

Page 38: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 38

Page 39: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 39

Page 40: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 40

Page 41: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 41

Page 42: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 42

Accessing Device Properties

Service Data Control EL Access Programmatic

Device Properties Yes Yes

Send SMS Yes Yes

Send Email Yes Yes

Page 43: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 43

PRODUCT DEMONSTRATION SENDING EMAIL via the Data Control

Page 44: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 44

Page 45: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 45

Page 46: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 46

Page 47: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 47

Page 48: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 48

Page 49: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 49

PRODUCT DEMONSTRATION SENDING EMAIL via a Java Bean

Page 50: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 50

01 public class oracle.adf.model.datacontrols.device.DeviceManager {

02

03 /** Display the operating system's default UI for sending an e-mail, and

04 * optionally pre-populate certain fields.

05 *

06 * @param to - recipient list (comma-separated)

07 * @param cc - carbon copy recipient list (comma-separated)

08 * @param subject - subject line

09 * @param body - text of e-mail

10 * @param bcc - blind carbon copy recipient list (comma-separated)

11 * @param attachments - list of files to attach (comma-separated). Must be

12 * specified as absolute filenames;

13 * @param mimeTypes - list of MIME types, specified in the same order as

14 * the list of attachments.

15 */

16 public void sendEmail(java.lang.String to, java.lang.String cc,

17 java.lang.String subject, java.lang.String body,

18 java.lang.String bcc, java.lang.String attachments,

19 java.lang.String mimeTypes)

Send Email API

Page 51: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 51

01 public class MyBean {

02

03 // Called via a button

04 public void actionSendEmail(ActionEvent event) {

05 DeviceManager device = DeviceManagerFactory.getDeviceManager();

06

07 String to = "[email protected], [email protected]";

08 String cc = "[email protected]";

09 String subject = "A test email subject";

10 String body = "A test email body";

11

12 device.sendEmail(to, cc, subject, body, null, null, null);

13 }

14 }

Send Email API Example

Page 52: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 52

Page 53: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 53

Page 54: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 54

Page 55: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 55

Page 56: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 56

Page 57: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 57

Page 58: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 58

Page 59: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 59

Page 60: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 60

Page 61: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 61

Page 62: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 62

Page 63: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 63

Accessing Device Properties

Service Data Control EL Access Programmatic

Device Properties Yes Yes

Send SMS Yes Yes

Send Email Yes Yes

Create Contact

Find Contacts

Update Contact

Remove Contact

Yes

Yes

Yes

Yes

Yes

Page 64: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 64

Working with Contacts

Operations –

– Find Contacts

– Create Contact

– Update Contacts

– Remove Contact

Both update and remove operations use a Contact object as a

parameter

– retrieved from a findContact operation

ADF Mobile provides a contact related objects

Page 65: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 65

PRODUCT DEMONSTRATION WORKING WITH CONTACTS via the Data Control

Page 66: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 66

Page 67: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 67

Page 68: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 68

Page 69: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 69

PRODUCT DEMONSTRATION WORKING WITH CONTACTS via a Java Bean

Page 70: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 70

01 public class oracle.adf.model.datacontrols.device.DeviceManager {

02

03 /** Save a previously-created Contact to the device's address book

04 * Note that you can create a Contact by simply instantiating one

05 * and setting its properties, but in order to persist it, you

06 * must call createContact.

07 *

08 * @param contact - a previously-constructed Contact object

09 * @return - a Contact object. Note that you should always

10 * use the returned Contact object in subsequent

11 * operations, because this object will have the

12 * requisite primary key

13 */

14 public Contact createContact(Contact contact)

Create Contact API

Page 71: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 71

01 public class MyBean {

02

03 public void actionCreateContact(ActionEvent event) {

04 DeviceManager device = DeviceManagerFactory.getDeviceManager();

05

06 Contact contact = new Contact();

07 contactName contactName = new ContactName();

08 contactName.setFamilyName("Doe");

09 contactName.setGivenName("Joe");

10 contact.setName(contactName);

11 ContactField phoneNo = new ContactField();

12 phoneNo.setType("mobile");

13 phoneNo.setValue("650-000-1234");

14 ContactField[] phoneNos = new ContactField[] { phoneNo };

15 contact.setPhoneNumbers(phoneNos);

16

17 Contact newContact = device.createContact(contact);

18 }

Create Contact API Example

Page 72: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 72

01 public class oracle.adf.model.datacontrols.device.DeviceManager {

02

03 /** Enables retrieval of one or more Contact objects matching the criteria.

04 *

05 * @param contactFields - comma-delimited list of field names to match on,

06 * e.g. "id,displayName,name,nickname”.

07 * @param filter - search criteria. It is matched against all fields

08 * specified in contactFields

09 * @param multiple - return multiple contacts or first found

10 * @return - an array of Contact objects. Note that each

11 * Contact object will ONLY contain the fields you

12 * specified in the contactFields parameter; all

13 * others will be empty/null

14 */

15 public Contact[] findContacts(java.lang.String contactFields,

16 java.lang.String filter, boolean multiple)

Find Contacts API

Page 73: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 73

01 public class MyBean {

02

03 public void actionFindContacts(ActionEvent event) {

04 DeviceManager device = DeviceManagerFactory.getDeviceManager();

05 // This will return just one contact with only the ID field:

06 Contact[] foundContacts1 = device.findContacts("", "", false);

07 // This will return all contacts with only ID fields:

08 Contact[] foundContacts2 = device.findContacts("", "", true);

09 // This will return just one contact with all fields:

10 Contact[] foundContacts3 = device.findContacts("*", "", false);

11 // This will return all contacts with all fields:

12 Contact[] foundContacts4 = device.findContacts("*", "", true);

13

14 String fields = "name,phoneNumbers,emails,addresses";

15 String filter = "Smith";

16 Contact[] contacts = device.findContacts(fields, filter, true);

17 }

Find Contacts API Example

Page 74: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 74

01 public class oracle.adf.model.datacontrols.device.DeviceManager {

02

03 /** Update an existing Contact object. Note that you can modify a

04 * Contact via its various properties and methods, but in order to

05 * persist the changes, you must call updateContact.

06 *

07 * @param aContact – the modified Contact object to persist in the

08 * device's address book.

09 * @return - the modified Contact object.

10 */

11 public Contact updateContact(Contact aContact)

Update Contact API

Page 75: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 75

01 public class MyBean {

02

03 public void actionUpdateContact(ActionEvent event) {

04 DeviceManager device = DeviceManagerFactory.getDeviceManager();

05

06 Contact[] contacts = device.findContacts("name", "Smith", true);

07 // Assuming only 1 record returned

08 contacts[0].getPhoneNumbers()[0].setValue("650-111-1234");

09 contacts[0].getEmails()[0].setType("work");

10 contacts[0].getAddresses()[0].setPostalCode("94065");

11

12 Contact updatedContact = device.updateContact(contacts[0]);

13 }

14 }

Update Contact API Example

Page 76: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 76

01 public class oracle.adf.model.datacontrols.device.DeviceManager {

02

03 /** Remove a contact from the address book.

04 *

05 * @param aContact – the Contact object to remove.

06 */

07 public void removeContact(Contact aContact);

Remove Contact API

Page 77: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 77

01 public class MyBean {

02

03 public void actionRemoveContact(ActionEvent event) {

04 DeviceManager device = DeviceManagerFactory.getDeviceManager();

05

06 Contact[] contacts = device.findContacts("name", "Smith", true);

07 // Assuming only 1 record returned

08 device.removeContact(contacts[0]);

09 }

10 }

Remove Contact API Example

Page 78: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 78

Accessing Device Properties

Service Data Control EL Access Programmatic

Device Properties Yes Yes

Send SMS Yes Yes

Send Email Yes Yes

Create Contact

Find Contacts

Update Contact

Remove Contact

Yes

Yes

Yes

Yes

Yes

Get Picture Yes Yes

Page 79: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 79

PRODUCT DEMONSTRATION ACCESSSING THE CAMERA via the Data Control

Page 80: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 80

Page 81: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 81

Page 82: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 82

Page 83: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 83

Page 84: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 84

Page 85: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 85

Page 86: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 86

PRODUCT DEMONSTRATION ACCESSSING THE CAMERA via a Java Bean

Page 87: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 87

01 public class oracle.adf.model.datacontrols.device.DeviceManager {

02

03 /** Provides access to the device's default camera application, which enables

04 * taking a picture or retrieving a previously-save image.

05 *

06 * @param quality – quality of save image. Range 0 to 100

07 * @param destinationType – Choose the format of the return value.

08 * - 0 – base64 encoded string – 1- URI to file:///

09 * @param sourceType - Where should the picture come from?

10 * - 0 – Library – 1 – Camera – 2 – Album

11 * @param allowEdit - Allow simple editing of image before selection

12 * @param encodingType - Encoding of saved imaged - 0 – JPG – 1 – PNG

13 * @param targetWidth - Width in pixels to scale image

14 * @param targetHeight - Height in pixels to scale image

15 * @returns - A String of either the base64 image or a file URK

16 */

17 public String getPicture(int quality, int destinationType, int sourceType,

18 boolean allowEdit, int encodingType,

19 int targetWidth, int targetHeight);

Get Picture API

Page 88: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 88

01 public class MyBean {

02

03 // Called via a button

04 public void actionGetPicture(ActionEvent event) {

05 DeviceManager device = DeviceManagerFactory.getDeviceManager();

06

07 String imageData =

08 device.getPicture(100,

09 DeviceManager.CAMERA_DESTINATIONTYPE_FILE_URL

10 DeviceManager.CAMERA_SOURCETYPE__PHOTOLIBRARY,

11 false,

12 DeviceManager.CAMERA_ENCODINGTYPE_JPEG,

13 0, 0);

14 }

Get Picture API Example

Page 89: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 89

Working With The Camera

Pay attention to picture quality

– File size impacts memore/network traffic

To return picture to the page:

– Set destinationType to 1 (file name)

– Drop Return of getPicture as Output Text

– Drop Image component onto page

– Set source to return input value (#{bindings.Return.inputValue})

Page 90: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 90

Accessing Device Properties

Service Data Control EL Access Programmatic

Device Properties Yes Yes

Send SMS Yes Yes

Send Email Yes Yes

Create Contact

Find Contacts

Update Contact

Remove Contact

Yes

Yes

Yes

Yes

Yes

Get Picture Yes Yes

Start Location

Monitor Yes Yes

Page 91: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 91

Working with Location Services

Acquire the device's current position

One instant in time, or on a periodic basis

Uses the startLocationMonitor operation

Use a geo-decoder to get address from coordinates

Page 92: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 92

PRODUCT DEMONSTRATION USING THE GPS via the Data Control

Page 93: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 93

Page 94: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 94

Page 95: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 95

Page 96: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 96

PRODUCT DEMONSTRATION USING THE GPS via a Java Bean

Page 97: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 97

01 public class oracle.adf.model.datacontrols.device.DeviceManager {

02

03 /** Register a callback to receive updates on the device's position

04 *

05 * @param updateInterval - how often to retrieve position(ms).

06 * @param enableHighAccuracy – receive best possible results at cost of

07 * increased power/computation expense.

08 * @param watchID - unique handle id that can be used to

09 * subsequently stop listening for updates.

10 * @param callback - an implementation of

11 * GeolocationCallback which can be invoked

12 * at updateInterval to deliver the

13 * device's location.

14 */

15 public java.lang.String startUpdatingPosition(

16 int updateInterval, boolean enableHighAccuracy,

17 java.lang.String watchID,GeolocationCallback callback)

Start Updating Position API

Page 98: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 98

01 public class MyBean {

02

03 // Called via a button

04 public void actionGetPicture(ActionEvent event) {

05 DeviceManager device = DeviceManagerFactory.getDeviceManager();

06

07 String watchID = device.startUpdatingPosition(20000,

08 true, "MyGPSSubscriptionID",

09 new GeolocationCallback() {

10 public void locationUpdated(Location position) {

11 System.out.println("Location updated to: " + position);

12 }

13 });

14 device.clearWatchPosition(watchID);

15 }

16 }

Start Updating Position API Example

Page 99: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 99

Summary

Accessing on device features is via an API wrapping PhoneGap

(Cordova)

– Refer to both the Oracle and 3rd party documentation

Dependent on the feature you can access it via EL expressions, the

data control or Java code

Some device features cannot be tested via the provided iOS

Simulator and Android emulator, only a real device will do

Page 100: 1 Copyright © 2012, Oracle and/or its affiliates. All ... … · 11hardware.screen.scaleFactorCopyright © 2012, Oracle and/or its affiliates. All rights reserved. Property Static/Dyna

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 100