Top Banner
BlackBerry Widgets Getting Started
95
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1:

BlackBerry Widgets

Getting Started

Page 2:

http://cmer.cis.uoguelph.ca

What is a Widget?

• Widgets are local web applications written in HTML/CSS/JavaScript

• Widgets can help deal with device heterogeneity as they are written in open web technologies

• Widgets also store information on the device as opposed to traditional web application which need to download the information each time

2

Page 3:

http://cmer.cis.uoguelph.ca

Blackberry Widgets

• Blackberry Widgets are standalone Blackberry device applications

• Composed of standard web components such as HTML, XHTML, style sheets, Javascript, SVG, and image files

• Follow same rules regarding security, configuration, and deployment as any other Blackberry application

3

Page 4:

http://cmer.cis.uoguelph.ca

Widget SDK

• Blackberry Widget SDK can be used to create Blackberry Widget applications

• Includes Blackberry Widget Packager, code samples, smartphone simulator, MDS Connection simulator, and documentation

• Widget development is tool independent• Any tool can be used to create Blackberry

Widgets and the Packager is used to compile the widgets

4

Page 5:

http://cmer.cis.uoguelph.ca

Widget Packager

• Command line tool that compiles web code to create Blackberry Widgets

• Creates executable application file (.cod) and installation file (.alx)

5

Page 6:

http://cmer.cis.uoguelph.ca

Widget Communication

• Widgets support push and pull communication

• Pull communication can be accomplished using XMLHttpRequest

• Pull communication can be synchronous or asynchronous

• Requests to external domains from your widget must match URLs that you provide using widget permissions

6

Page 7:

http://cmer.cis.uoguelph.ca

Widget Communication

• Push communication is accomplished through a backend server

• blackberry.push and blackberry.push.Data enable the device to use push technology

• Widgets can operate in the background freeing the user to do other work

7

Page 8:

http://cmer.cis.uoguelph.ca

Widget Configuration Document

• XML file that contains the elements to define the namespace, name of widget, widget permissions, elements to set the start page, icons to use, author, email address, and license information

• Contains widget element at its root• Configuration document must be in root

directory of Blackberry Widget archive

8

Page 9:

http://cmer.cis.uoguelph.ca

Widget Configuration Document Example

• A valid configuration document is named config.xml and is case sensitive and must be in root folder of widget archive

• Below is sample code for a configuration document:

<?xml version="1.0" encoding="utf-8"?>

<widget xmlns=" http://www.w3.org/ns/widgets" xmlns:rim="http://www.blackberry.com/ns/widgets" version="2.0" rim:header="RIM-Widget: rim/widget">

<name> The example widget</name>

<description> A sample widget to demonstrate some of the possibilities. </description>

<icon src="icons/example.png"/>

9

Page 10:

http://cmer.cis.uoguelph.ca

Widget Configuration Document Example

<icon src="icons/boo.png" rim:hover="true"/>

<content src="index.jsp"/>

<feature id="blackberry.ui.dialog" required="true" version="1.0.0"/>

<access uri="http://www.somedomain.com" subdomains="true">

<feature id="blackberry.pim.memo" required = "true" version="1.0.0"/>

<feature id="blackberry.invoke.MemoArguments" required = "true" version="1.0.0"/>

</access>

<rim:connection timeout="25">

<id>TCP_WIFI</id>

<id>MDS</id>

<id>BIS-B</id>

<id>TCP_CELLULAR</id>

<id>WAP2</id>

<id>WAP</id>

</rim:connection>

10

Page 11:

http://cmer.cis.uoguelph.ca

Widget Configuration Document Example

<license>

Example license

Copyright (c) 2008 The Acme Corp.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION

OF CONTRACT, INSULT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE

OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

</license>

</widget>

11

Page 12:

http://cmer.cis.uoguelph.ca

Configuration Elements - Namespace

• The following are the elements and their attributes that are found in the Widget Configuration document

• Widget namespace– Widget namespaces must be assigned to widget

elements otherwise the archive is invalid

– The widget namespace is http://www.w3.org/ns/widgets

– The namespace for BlackBerry-specific widget extensions is xmlns:rim http://www.blackberry.com/ns/widgets

12

Page 13:

http://cmer.cis.uoguelph.ca

Configuration Elements - Widget

• Widget element– Root element– Inside the Widget element the following rules apply

for all other elements• one name element • zero or one description elements • zero or more icon elements • zero or more access elements • zero or one content elements • zero or more feature elements • zero or one rim:loadingScreen elements • zero or one rim:connection elements

13

Page 14:

http://cmer.cis.uoguelph.ca

Configuration Elements - Widget

– version• Required• Specifies valid version for Widget in following format

– a.b

– a.b.c

– a.b.c.d

• Widget archive invalid if invalid version number is used

– rim:header• Optional• Precedes every request for data allowing you to

differentiate from browser requests

14

Page 15:

http://cmer.cis.uoguelph.ca

Configuration Elements - Widget

– id• Optional• Unique Widget identifier

– xml:lang• Optional• Language used in element, en for English

15

Page 16:

http://cmer.cis.uoguelph.ca

Configuration Elements - Name

• Name element– Specifies a human-readable name for a Widget– Missing name element makes the Widget invalid– blackberry.app.name in the Widget API can also be

used to provide a name– xml:lang

• Optional• Defines language used in element

– its:dir• Specifies direction of language such as right to left,

its:dir="rtl"• Used for localization

16

Page 17:

http://cmer.cis.uoguelph.ca

Configuration Elements – Description

• Description element– Description for Widget– blackberry.app in the Widget API may be used– xml:lang and its:dir also in this element

17

Page 18:

http://cmer.cis.uoguelph.ca

Configuration Elements - Icon

• Icon element– Optional– First icon element without rim:hover set to True is

main icon for Widget– blackberry.app.setHomeScreenIcon(src, rim:hover) in

Widget API may also be used– src

• Required• Specifies path for icon

– rim:hover• Optional, default value is false• Specifies icon to use as hover icon

18

Page 19:

http://cmer.cis.uoguelph.ca

Configuration Elements - Access

• Access element– Allows permission to access external network

resources– By default Widget has access to all local resources– URI

• Required• Defines address for access request

– Subdomains• Optional• Boolean value that allows for subdomains of URI to have

access requests

19

Page 20:

http://cmer.cis.uoguelph.ca

Configuration Elements - Feature

• Feature element– Specifies API that Widget can use– Can be used within access element to access

feature in external domain– Can be used in root of configuration document

before any access elements to access the local page

– If no API is specified the feature cannot be used by the Widget

20

Page 21:

http://cmer.cis.uoguelph.ca

Configuration Elements - Feature

• Feature element– id

• Required• Identifies API to be used, name must match API but is not

case sensitive, (*) may be used for multiple namespaces

– required• Optional• Provided for conformance to W3C specifications

– version• Optional• Specifies library version of APIs

21

Page 22:

http://cmer.cis.uoguelph.ca

Configuration Element - Content

• Content element– Identifies start file to use when Widget starts– If none present default file from archive is used– src

• Required• Source HTML file within Widget archive

– type• Optional• MIME type of file in src

– charset• Optional• Identifies character set that is used in src

22

Page 23:

http://cmer.cis.uoguelph.ca

Configuration Element – RIM loadingScreen

• RIM loadingScreen element– Identifies properties of loading screen that

appears when Widget starts– backgroundColor

• Optional• Identifies HEX colour value to display before start page

appears

23

Page 24:

http://cmer.cis.uoguelph.ca

Configuration Element – RIM connection

• RIM connection element– Specifies connection preference for device– timeout

• Optional• Default timeout is 30000 ms• Time must be in ms and valid numerical value otherwise

ignored• Overrides default timeout when device attempts to

connect to a particular transport

24

Page 25:

http://cmer.cis.uoguelph.ca

Configuration Element – RIM connection

• ID element– Optional– Identifies type and order of communication

transports that will be used for Widget– Default order is following:

• MDS: BlackBerry® Enterprise Server • BIS-B: BlackBerry® Internet Service • TCP_WIFI: Wi-Fi® network • TCP_CELLULAR: Direct TCP stack • WAP2: Service provider WAP 2.0 gateway • WAP: Service provider WAP 1.0 gateway

25

Page 26:

http://cmer.cis.uoguelph.ca

Widget Archive

• A .zip file that is compiled by Widget Packager to create a Blackberry Widget

• Widget archive contains:– Configuration document– Start page– Application icons– Other resources and objects referenced in your

web pages

• Widgets should be stored outside Widget Packager installation directory

26

Page 27:

http://cmer.cis.uoguelph.ca

Widget Archive – Start Page

• Start page is the page that is displayed to the user upon starting the Widget

• If a start page is not defined in configuration document or error occurs a default start file is used

• The default name in search order is index.htm or Index.jsp

• Default MIME is text/html and the default search is case insensitive

• External start pages may also be used27

Page 28:

http://cmer.cis.uoguelph.ca

Widget Archive – Application Icons

• Custom icons may be used to show your Widget

• The application icon is the icon when the Widget has not been highlighted

• Default name is icon.gif or .png and must exist in root directory of Widget archive

• The config document may also be used to set the icon– <icon src="icons/appicon.gif"/>

28

Page 29:

http://cmer.cis.uoguelph.ca

Widget Archive – Hover Icons

• The hover icon is the icon that is displayed when the user is on the Widget

• The icon can be set in the configuration document– <icon src="icons/appfocus.gif"

rim:hover="true"/>

• If no hover icon is set the default application icon is used

29

Page 30:

http://cmer.cis.uoguelph.ca

Reserved Names

• config.xml– Widget Configuration Document

• signature[0..9].xml– Blackberry Signature Tool Configuration

• icon.gif or icon.png– Default icon

• Thumbnail.gif or Thumbnail.png– Thumbnail graphics

• index.htm or index.jsp– Default start page

30

Page 31:

http://cmer.cis.uoguelph.ca

Gears

• Set of Javascript extensions that is exposed through Blackberry Widget APIs

• Used to create applications that extend beyond browser platform

• Key features:– Persistent client-side data storage– Ability to run multiple Javascripts in parallel

31

Page 32:

Blackberry WidgetsRelated Work

32

Page 33:

http://cmer.cis.uoguelph.ca

PhoneGap

• Open source development tool for building mobile apps with HTML/CSS/Javascript

• Compatible with Android, iPhone, and Blackberry

• Attempt to cover many different devices from different manufacturers in one development tool

33

Page 34:

http://cmer.cis.uoguelph.ca

Rhomobile

• Cross-platform development tool which is based on MVC framework

• Views are written in HTML and the application is compiled in the device’s native language

• Some advanced functionality recommends additional Rhomobile products such as a sync server

• Applications may not have exact look and feel of native applications on devices

34

Page 35:

Blackberry WidgetsDesign Principles

35

Page 36:

http://cmer.cis.uoguelph.ca

Design Considerations

• Mobile devices– Smaller screen size– Slower processor– Wireless networks have longer latency– Less available memory– Shorter battery life– One screen display

36

Page 37:

http://cmer.cis.uoguelph.ca

Design Considerations

• When designing a Blackberry Widget consider:– Using or extending existing UI components so

application can inherit default behaviour of component

– Modifying standard navigation model– Making all actions that are relevant to user’s

context available in menu– Simplifying data selection and presentation to

information only user needs at given moment

37

Page 38:

http://cmer.cis.uoguelph.ca

Design Considerations for Device

• Unless designed for one device in mind, application should be usable on as many devices as possible

• Widgets do not support zooming or column views like Blackberry browsers do

38

Page 39:

http://cmer.cis.uoguelph.ca

Design Considerations for Device

• Use Cascading Style Sheets to control presentation when possible– Create a single HTML file with multiple CSS files

rather than multiple HTML files with different formatting

• Create pages that are viewable on wide and narrow screens– Can be done through multiple CSS files or by

percentage of screen size

39

Page 40:

http://cmer.cis.uoguelph.ca

Design Considerations for Device

• Pages should resize properly on devices that have a touchscreen

• The following code shows how to use Javascript to identify orientation of screen– function resetHeight() {

document.getElementById("mainBody").style.height = screen.height+"px"; }

<body id="mainBody“ onload="javascript:resetHeight();" >

40

Page 41:

http://cmer.cis.uoguelph.ca

Design Considerations for Device

• The below code shows how to reset the page height when the orientation changes– window.onorientationchange = function()

{ document.getElementById("mainBody").style.height = screen.height+"px"; }

41

Page 42:

http://cmer.cis.uoguelph.ca

Design Considerations for Device

• Content should be designed with so as not being dependent on a single input method– Testing should be done to see how trackball

events, touch screen events and keyboard inputs are treated on different devices

42

Page 43:

http://cmer.cis.uoguelph.ca

Design Considerations for Device

• Widgets make HTTP requests which contain a Profile header

• This header provides information about the device such as model number and software version in <BlackBerry-model> and <software-version>

• Profile Header– http://www.blackberry.net/go/mobile/profiles/

uaprof/<BlackBerry-model>/<software-version>.rdf

43

Page 44:

http://cmer.cis.uoguelph.ca

Design Considerations for Users

• Focus on the user experience– Know who will use your Widget, what their needs

and expectations are, and how your Widget will meet them

• Balance need of feature rich content on Widgets with fast loading times– Understanding users will allow you to make

better informed decisions on the content they require

44

Page 45:

http://cmer.cis.uoguelph.ca

Design Considerations for Users

• Avoid designs where content is distant from your users– Keep the number of clicks users have to make to

reach content to a minimal

• Widgets should be easy to view on device– Content should be visible without using zoom and

column view

– Use <meta> tags to control the initial scale of content

– Avoid absolute positioning on a screen that requires vertical scrolling, this causes stuttering

45

Page 46:

http://cmer.cis.uoguelph.ca

Design Considerations for Wireless Networks

• Send only the information necessary and send it as efficiently as possible

• Content to be delivered over the wireless network must:– Avoid costing the user an increasing amount of

money as some may pay per the data transferred– Conscious of network bandwidth, wireless

networks are usually slower than wired networks so content must be designed with that in mind

46

Page 47:

http://cmer.cis.uoguelph.ca

Design Considerations for Wireless Networks

• Apply some concepts for efficient web content design to your widgets– Structural HTML to create logical HTML blocks in

code using <div> for content blocks and <h1,h2,..> for hierarchies

– CSS to control layout and presentation– Separate files for content, presentation, and

interaction. External CSS and scripts files can be reused when visiting your page.

• Inline and internal styles and scripts are less efficient and over time require more transfers

47

Page 48:

http://cmer.cis.uoguelph.ca

Design Considerations for Wireless Networks

• One can also minimize impact of slower wireless networks by:

• Users need to make fewer requests to reach content– Less requests means less transfers of data in a

slow network. Efficient Widgets should have clear navigation, clear labels, and well-designed pages

48

Page 49:

http://cmer.cis.uoguelph.ca

Design Considerations for Wireless Networks

• Scripting techniques to progressively render pages– Consider loading portions of the content in

phases. Load an initial portion then use XMLHttpRequest to load the remaining content so that the user is not blocked from doing work while the content loads.

– You may also use HttpRequest from Gears which can work in a WorkerPool making it even more efficient

49

Page 50:

http://cmer.cis.uoguelph.ca

Design Considerations for Wireless Networks

• Widgets should push content proactively– You can use the Blackberry technology to send

content before the user requests it, that way once I user needs that content it is ready for them to use and they do not need to wait for it to be downloaded by the Widget

50

Page 51:

http://cmer.cis.uoguelph.ca

Supported Standards and Content Types

• Know the standards and content types supported by the Blackberry Widget

• Web standard supports can be found here:– Supported Web Standards– Supported Gears APIs

51

Page 52:

Blackberry WidgetsBlackberry Integration

52

Page 53:

http://cmer.cis.uoguelph.ca

Integrating Blackberry Device Features

• Integrating device features provides a better experience for users of your Widget

• Create links that will automatically dial phone numbers when clicked

• Widgets support the following types:• WTAI Make Call links (URI form)– <a href="wtai://wp/mc;14165551212">Call

office</a>

53

Page 54:

http://cmer.cis.uoguelph.ca

Integrating Blackberry Device Features

• I-mode format– <a href="tel:14165551212">Call office</a>

• Direct Connect links on iDen networks– <a href="dc:234*234*234">Call office</a>

• CTI– <a href="cti:333333">Call office</a>

• blackberry.identity.phone can be used to access information about the device’s phone lines

54

Page 55:

http://cmer.cis.uoguelph.ca

Integrating Blackberry Device Features

• GPS can be used to provide unique location based services on devices that have the feature available

• Two methods to access GPS information– BlackberryLocation object in Javascript– Gears GeoLocation API

• GeoLocation API provides more detail than BlackberryLocation but at a higher resource cost

55

Page 56:

http://cmer.cis.uoguelph.ca

Integrating Blackberry Device Features

• Media can be used to augment your content. Blackberry Browser supports a variety of codecs

• Always be aware of the size of media you are transferring to the user and the potential costs in both time and money for the user

56

Page 57:

http://cmer.cis.uoguelph.ca

Integrating Blackberry Device Applications

• Consider also integrating your Widget with existing Blackberry applications to provide a more complete experience

• For example you may invoke:– Calendar to display appointments– Address book to display content– Browser to open website– Phone to dial number

57

Page 58:

http://cmer.cis.uoguelph.ca

Accessing Email and Organizer Data

• The blackberry.pim object can be used to access PIM information from:– Email messages– Contacts– Calendar entries– Tasks– Call logs

• Widgets can read, write, and modify entries as long as resources are defined in configuration document

58

Page 59:

http://cmer.cis.uoguelph.ca

Custom Menus

• Blackberry.menu.ui object in Blackberry Widget API can be used to add custom menu items

• Custom menus can provide users additional functionality such as showing the location of the email sender

• As a user clicks on a sender’s email address they Widget can reference the contact list and use the Gears Geolocation API to show a map with the sender’s location

59

Page 60:

Blackberry WidgetsSecurity Considerations

60

Page 61:

http://cmer.cis.uoguelph.ca

External Resource and API Access

• Widgets cannot access external resources by default

• To access external resources and APIs they must be defined in the Widget configuration document

• Define a list of domains and the Widget APIs that can be accessed by them

• List can be defined using Widget permissions or a white list

61

Page 62:

http://cmer.cis.uoguelph.ca

External Resource and API Access

• To make the widget as secure as possible when accessing external content consider:– Javascript access to sensitive APIs only to

trusted and secure web sites– Use HTTPS when exposing sensitive APIs for

communication– Use precautions that protect against cross-site

scripting attacks

62

Page 63:

http://cmer.cis.uoguelph.ca

External Resource and API Access

• To allow your Widget to access data from changing domains or unknown domains use the wildcard character

• Web pages cannot use any of the Blackberry Widget APIs when the widget accesses them from an external source using the wildcard character– <access uri ="*"/>

63

Page 64:

http://cmer.cis.uoguelph.ca

External Resource and API Access

• To access functionality in a domain your Widget must use the access and feature elements

• In the below example features of the mydomain you specify are accessable– <access uri ="mydomain" subdomains="true"> – <feature id=" . . . /> – <feature id=" . . . /> – </access>

64

Page 65:

http://cmer.cis.uoguelph.ca

Signing your Blackberry Widget

• Blackberry Widget Packager includes Blackberry Signature Tool

• Applications that use controlled APIs need signatures from the Blackberry Signing Authority Tool

65

Page 66:

http://cmer.cis.uoguelph.ca

Authentication

• Device users can set passwords on the devices that limit access to applications such as Widgets on their device

• IT Administrators can set special IT policies to through the Blackberry Enterprise Server to ensure devices in a company are password protected

66

Page 67:

http://cmer.cis.uoguelph.ca

Authentication

• If additional security is required for sensitive Widgets you may consider adding a login screen at the start of the application

• Blackberry allows for input fields that hide the characters entered for items such as passwords

67

Page 68:

http://cmer.cis.uoguelph.ca

Authentication

• An additional method of authentication may be added if the Widget accesses an application on a server

• You may require the Widget provide a username and password which can be accomplished through simple HTTP authentication, adding the information in the HTTP header

• Certificates may also be used for authentication

68

Page 69:

http://cmer.cis.uoguelph.ca

Application Control

• IT Administrators can control the applications that are allowed on a Blackberry device through the application control policy

• In order for this to be accomplished the Blackberry must be associated with a Blackberry Enterprise Server

69

Page 70:

http://cmer.cis.uoguelph.ca

File Encryption

• Files that are accessed by the Widget are decrypted and moved from the microSD card to the Blackberry device

• Files with a .rem extension can only be decrypted on a Blackberry

• A master key stored on the microSD media card is used to encrypt and decrypt BlackBerry device media files

70

Page 71:

http://cmer.cis.uoguelph.ca

Memory Access

• Widgets may only write to memory the Java Virtual Machine uses

• Widgets cannot access memory or persistent storage of other applications unless granted

• Access to persistent storage, data, or communication to applications is limited to specific Blackberry Widget APIs

71

Page 72:

http://cmer.cis.uoguelph.ca

Memory Access

• Gears applications can only access resources with the same scheme, domain, and port number, as the application

• Widgets create a database in a domain-specific subfolder inside a Gears specific subfolder

• A Gears application located at www.mycompany.com/gearsapp translates to /BlackBerry/system/appdata/rim/gears/mycompany/com

72

Page 73:

http://cmer.cis.uoguelph.ca

Memory Access

• An application can access a database only by using path names that are relative to the origin domain

• Applications cannot access databases using absolute path names

• As in the Gears specification, Widgets do not allow access to SQLite commands that can potentially compromise security, such as ATTACH DATABASE, DETACH DATABASE, and PRAGMA

73

Page 74:

http://cmer.cis.uoguelph.ca

Memory Access

• User permission is required for scripts that access storage space or functionality outside the scope of the Widget

• A dialog box is presented to the user for their permission

• Permissions are stored in database on media card either internal or external or in temporary cache

• Permissions remain until user changes settings or cache is cleared

74

Page 75:

http://cmer.cis.uoguelph.ca

Data Encryption

• Data is encrypted when a Blackberry is connected through a Blackberry Enterprise Server

• Encryption is done with AES or TripleDES between the device and Enterprise Server, encryption outside the Server can be done through HTTPS or STL/TLS encryption

• Data is not encrypted when using the Blackberry Internet Service

75

Page 76:

Blackberry WidgetsCompilation

76

Page 77:

http://cmer.cis.uoguelph.ca

Widget Compilation Process

• When a Widget is compiled the Widget Packager takes the following steps:1. Contents of Widget archive are validated

2. Output file folder is created

3. Creates source target folder if needed

4. Creates .cod, .alx, .jad, .cso, and .csl files for various distribution methods and signing

5. Signed Widgets need updated .cod file

77

Page 78:

http://cmer.cis.uoguelph.ca

Install the new registry key with the BlackBerry Signature Tool

• In the BlackBerry Developer Zone at https://www.blackberry.com/SignedKeys, complete the registration form. After you complete the form, RIM will send an email message containing a .csi file. The .csi file contains a list of signatures, along with your registration information

• At the command prompt, navigate to the bin folder within the BlackBerry Widget Packager installation directory

• Type the following command, including the full path of the .csi file: java -jar SignatureTool.jar <.csi file path>

• If a dialog that a private key cannot be found appears, perform the following actions: – Click Yes. – Type a password for the private key. – Type the password to confirm it. – Click OK. – Move the mouse to generate data for the new private key.

• In the Registration PIN field, type the PIN that RIM provided• In the Private Key Password field, type a password of at least eight characters. This is the

private key password• Click Register • Click Exit

78

Page 79:

http://cmer.cis.uoguelph.ca

Widget Compilation Process

• To compile a widget:– Run the Widget Packager from the installation

folder in the command prompt– Compile by using the following command:

bbwp “[drive:] [path] archive” [/s [dir]] [/[-]g [password]] [/o dir]

– Ensure the path is correct and a bbwp.properties file exists

79

Page 80:

http://cmer.cis.uoguelph.ca

Widget Compilation Process Parameters

• archive– Identifies .zip Widget archive to compile

• /g– Signs a .cod file with given password, default is /-g for

unsigned Widget

• /o– Saves output files to given folder, if not specified

same path as Widget archive is used

• /s– Saves source files to specified folder, if none

specified same path as Widget archive is used

80

Page 81:

http://cmer.cis.uoguelph.ca

Widget Compilation Process Best Practices

• Resource names should be consistent and correct– You should only use alphanumeric names and

file names and references are case sensitive

• All required elements should be in configuration document– At minimum namespace, Widget, version, and

name elements are defined

• Ensure required elements of your Widget are defined in configuration document

81

Page 82:

Blackberry WidgetsTesting and Distribution

82

Page 83:

http://cmer.cis.uoguelph.ca

Testing

• You may use the Smartphone simulator to test your Blackberry Widgets– On the Start menu, select Programs > Research In Motion >

BlackBerry Widget Packager > BlackBerry Smartphone Simulator

– After the Smartphone Simulator starts and you can see the Home screen, on the File menu, select Load Java Program

– Navigate to the output folder for your BlackBerry Widget and select the widget .cod file you want to run

– Click Open– On the Applications screen, open the Downloads folder– In the Downloads folder, click the BlackBerry Widget you

created

83

Page 84:

http://cmer.cis.uoguelph.ca

Testing

• You may test your Widget on a physical device

• Using the javaloader you can upload your application

• You may use the following command in the command prompt:– JavaLoader [-usb] [-pport] [-bbps] [-wpassword]

load file

84

Page 85:

http://cmer.cis.uoguelph.ca

Testing

• Port– The serial port to which the device connects

(default is COM1), or a device PIN if the device connects to a USB port, which the –usb option must be specified

• Bps– The bit rate speed to the serial port (default is

115200)

85

Page 86:

http://cmer.cis.uoguelph.ca

Testing

• Password– Password for Blackberry device if set

• File– .cod files that will be loaded on the device– If .cod file is not in same folder full path must be

specified

86

Page 87:

http://cmer.cis.uoguelph.ca

Distribution

• Blackberry Widgets can be distributed to users through:– Blackberry App World– Wireless Network through Blackberry Browser– Blackberry Desktop Manager– Blackberry Application Web Loader– Wireless Push from the Blackberry Enterprise

Server

87

Page 88:

Blackberry WidgetsSample Applications

88

Page 89:

http://cmer.cis.uoguelph.ca

HTML Code<html>

<head>

<title>Hello World Example</title>

<script src="Scripts/action.js" type="text/javascript"></script>

<link href="Styles/simple.css" rel="stylesheet" type="text/css" />

<style type="text/css">

#txtCount

{

width: 128px;

}

</style>

</head>

<body>

<p>

Hello, welcome to a very simple example of how to use a BlackBerry Widget. This sample will just increment the counter below as you hit the button.

</p>

<input type="text" id="txtCount" value="Clicked 0 times" />

<br />

<button id="btnAppend" onclick="append();">Increment Counter</button>

</body>

</html>

Execution

89

HelloWorld App

Page 90:

http://cmer.cis.uoguelph.ca

Upcoming Appointments Script Code

function LoadAppts() {

var date = new Date();

//use the blackberry API's to create your filter object

var filter = new blackberry.find.FilterExpression("start", ">=", date);

//use the blackberry API's to retrieve all of the appointments on the device that pass the filter

var appts = blackberry.pim.Appointment.find(filter);

//modify your html to display a list of the appointments that passed the filter. This will add them

//to a table for upto the next 10 appointments.

var table = document.getElementById("appts");

for (i = 0; i < appts.length || i == 10; i++) {

var start = appts[i].start;

var summary = appts[i].summary;

var row = document.createElement("TR");

var startCell = document.createElement("TD");

var summaryCell = document.createElement("TD");

90

Page 91:

http://cmer.cis.uoguelph.ca

Upcoming Appointments Script Code

startCell.setAttribute('class', 'appListItem');

summaryCell.setAttribute('class', 'appListItem');

var startFormatted = start.toLocaleDateString() + "-" + start.toLocaleTimeString();

var startText = document.createTextNode(startFormatted);

var summaryText = document.createTextNode(summary);

startCell.appendChild(startText);

summaryCell.appendChild(summaryText);

row.appendChild(startCell);

row.appendChild(summaryCell);

table.appendChild(row);

}

}

91

Page 92:

http://cmer.cis.uoguelph.ca

Upcoming Appointments

92

Page 93:

http://cmer.cis.uoguelph.ca

FileIO Gears Shopping List

93

Additional Examples

Page 94:

http://cmer.cis.uoguelph.ca

Tools

• BlackBerry Java Application Development v5.0 Beta 5 - http://na.blackberry.com/eng/developers/devbetasoftware/javasdk5.jsp

• BlackBerry Widget Sample -http://docs.blackberry.com/en/developers/subcategories/?userType=21&category=BlackBerry+Widgets&subCategory=BlackBerry+Widget+Sample+Applications

• Blackberry Widget SDK - http://na.blackberry.com/eng/developers/devbetasoftware/widgetsdk.jsp

• BlackBerry Web Plug-in - http://na.blackberry.com/eng/developers/devbetasoftware/eclipseplugin.jsp

94

Page 95:

http://cmer.cis.uoguelph.ca

References

• "BlackBerry Widgets - Manuals and Guides." BlackBerry - Manuals and Guides. Web. 18 Dec. 2009. http://docs.blackberry.com/en/developers/categories/?userType=21&category=BlackBerry+Widgets

• Koch, Peter-Paul. "QuirksBlog: Introduction to W3C Widgets." QuirksMode - for all your browser quirks. Web. 16 Dec. 2009. http://www.quirksmode.org/blog/archives/2009/04/introduction_to.html

• PhoneGap | Cross platform mobile framework. Web. 18 Dec. 2009. http://phonegap.com/

• Rhomobile - the open mobile framework. Web. 18 Dec. 2009. http://rhomobile.com/

• "Widget Packaging and Configuration." World Wide Web Consortium (W3C). Web. 18 Dec. 2009. http://www.w3.org/TR/2009/CR-widgets-20091201/

95