BlackBerry Development (for Web Developers) Kevin Falcone - - PowerPoint PPT Presentation

blackberry development
SMART_READER_LITE
LIVE PREVIEW

BlackBerry Development (for Web Developers) Kevin Falcone - - PowerPoint PPT Presentation

BlackBerry Development (for Web Developers) Kevin Falcone kevin@jibsheet.com Thursday, July 22, 2010 Perl developer Request Tracker Hiveminder BlackBerry owner Severely lapsed Java programmer Thursday, July 22, 2010


slide-1
SLIDE 1

BlackBerry Development

(for Web Developers)

Kevin Falcone

kevin@jibsheet.com

Thursday, July 22, 2010

slide-2
SLIDE 2
  • Perl developer
  • Request Tracker
  • Hiveminder
  • BlackBerry owner
  • Severely lapsed Java programmer

Thursday, July 22, 2010

slide-3
SLIDE 3
  • Hiveminder has an API
  • json
  • xml
  • It also has a mobile site

Thursday, July 22, 2010

slide-4
SLIDE 4

Mobile Site

Thursday, July 22, 2010

slide-5
SLIDE 5

Mobile Site

  • The BB Browser through OS 5.0 is terrible
  • 6.0 looks sexy... in the videos

Thursday, July 22, 2010

slide-6
SLIDE 6

My Assumptions

  • API
  • Java
  • Better mobile experience

Thursday, July 22, 2010

slide-7
SLIDE 7

Java

JVM Java ME RIM APIs Your App Device OS

Thursday, July 22, 2010

slide-8
SLIDE 8

Java

  • Can't use the new shiny
  • J2ME (now Java ME)
  • MIDP and CLDC

Thursday, July 22, 2010

slide-9
SLIDE 9

Thursday, July 22, 2010

slide-10
SLIDE 10

Choose Your Targets

Thursday, July 22, 2010

slide-11
SLIDE 11

Choose Your Targets

  • Many screen resolutions
  • Different carriers
  • Carrier assisted location
  • Different keyboard layouts
  • Pearl (2 letters to a key)
  • Small Flash storage (app storage)

Thursday, July 22, 2010

slide-12
SLIDE 12

Choose Your Targets

  • 4.3
  • 4.5
  • 4.6 and 4.6.1
  • 4.7.1
  • 5.0
  • 6.0?

Thursday, July 22, 2010

slide-13
SLIDE 13

Choose Your Targets

  • 4.3
  • 2007 vintage
  • old Curves, Pearls
  • Hopefully you can avoid supporting this
  • Simulator restarts are really fast

Thursday, July 22, 2010

slide-14
SLIDE 14

Choose Your Targets

  • 4.5
  • Lots and lots of older cheap curves
  • Verizon / T
  • Mobile

Thursday, July 22, 2010

slide-15
SLIDE 15

Choose Your Targets

  • 4.6
  • original Bold
  • larger screen/cpu/ram

Thursday, July 22, 2010

slide-16
SLIDE 16

Choose Your Targets

  • 4.7
  • Original Storm
  • First touchscreen, parallel development

Thursday, July 22, 2010

slide-17
SLIDE 17

Choose Your Targets

  • 4.6.1
  • Curve
  • 4.7.1
  • Javelin

Thursday, July 22, 2010

slide-18
SLIDE 18

Choose Your Targets

  • 5.0
  • Storm2, Bold2, Pearl and Curve 3g
  • Trackpad devices
  • At least 10 devices able to upgrade

Thursday, July 22, 2010

slide-19
SLIDE 19

Choose Your Targets

  • 5.0
  • SQLite
  • Location services
  • Better browser, still not great
  • New layout managers
  • ConnectionManager

Thursday, July 22, 2010

slide-20
SLIDE 20

Choose Your Targets

  • 6.0
  • Webkit browser
  • Who knows what else

Thursday, July 22, 2010

slide-21
SLIDE 21

Choose Your Targets

  • Different point releases per-carrier

Thursday, July 22, 2010

slide-22
SLIDE 22

Choose Your Targets

  • Networking
  • BES
  • BIS-B
  • Direct TCP (APN)
  • WAP2

Thursday, July 22, 2010

slide-23
SLIDE 23

Choose Your Targets

  • Simulators
  • simulate the hardware
  • simulate some failure modes
  • can only do some networking modes
  • location testing

Thursday, July 22, 2010

slide-24
SLIDE 24

Getting Started

Thursday, July 22, 2010

slide-25
SLIDE 25
  • Eclipse - cross platform
  • Simulators - older ones run under wine
  • Code Signing - mostly cross platform
  • Building/signing is automatable
  • bb-ant-tools

Thursday, July 22, 2010

slide-26
SLIDE 26
  • I just use

VMWare

  • share my document dirs back to OS-X
  • manage git from OS-X

Thursday, July 22, 2010

slide-27
SLIDE 27
  • Eclipse
  • One enormous bundle from RIM
  • JDE
  • Older technology
  • Stable

Thursday, July 22, 2010

slide-28
SLIDE 28
  • Eclipse ships with a specific JDK (5.0)
  • Download other versions from the normal

updater

  • Includes demos
  • Leverages some of the Eclipse magic for

building bb package com.rim.samples.device.helloworlddemo;

Thursday, July 22, 2010

slide-29
SLIDE 29
  • rapc
  • compiles into .cod files
  • simulator
  • mds simulator
  • cod signer

Thursday, July 22, 2010

slide-30
SLIDE 30

Hello World Again

Thursday, July 22, 2010

slide-31
SLIDE 31

package com.sample.helloworlddemo; public class HelloWorldDemo extends UiApplication { public static void main(String[] args) { HelloWorldDemo theApp = new HelloWorldDemo(); theApp.enterEventDispatcher(); } public HelloWorldDemo() { pushScreen(new HelloWorldScreen()); } } final class HelloWorldScreen extends MainScreen { HelloWorldScreen() { setTitle("Hello World Demo"); add(new RichTextField("Hello World!", Field.NON_FOCUSABLE)); } public void close() { Dialog.alert("Goodbye!"); super.close(); } }

Thursday, July 22, 2010

slide-32
SLIDE 32

package com.rim.samples.device.helloworlddemo; public class HelloWorldDemo extends UiApplication { public static void main(String[] args) { HelloWorldDemo theApp = new HelloWorldDemo(); theApp.enterEventDispatcher(); } public HelloWorldDemo() { pushScreen(new HelloWorldScreen()); } }

Thursday, July 22, 2010

slide-33
SLIDE 33

final class HelloWorldScreen extends MainScreen { HelloWorldScreen() { setTitle("Hello World Demo"); add(new RichTextField("Hello World!", Field.NON_FOCUSABLE)); } public void close() { Dialog.alert("Goodbye!"); super.close(); } }

Thursday, July 22, 2010

slide-34
SLIDE 34

Thursday, July 22, 2010

slide-35
SLIDE 35

Thursday, July 22, 2010

slide-36
SLIDE 36
  • Incredibly basic demo
  • TextField
  • Almost always need to subclass
  • Simple things can be done from the API
  • Fun math vs Images

Thursday, July 22, 2010

slide-37
SLIDE 37

final class MyEditField extends BasicEditField { String _text; int _width; public MyEditField(String label,String initialValue) { super(); _text = initialValue; } protected void paint(Graphics g) { super.paint(g); doDecoration(g); } private void doDecoration(Graphics g) { int _height = this.getHeight(); if (_width == 0 ) { _width = this.getWidth(); } for (_x = _width; _x >= 0; _x = _x - 2) { g.drawPoint(_width - _x,_height- 1); } } }

Thursday, July 22, 2010

slide-38
SLIDE 38
  • ActiveAutoTextEditField
  • corrects text entry for users

Thursday, July 22, 2010

slide-39
SLIDE 39
  • AutoCompleteField
  • define autocompletion behavior
  • make your owner field pull email

addresses from the contact book

Thursday, July 22, 2010

slide-40
SLIDE 40

BasicFilteredList filterList = new BasicFilteredList(); filterList.addDataSource( 1, BasicFilteredList.DATA_SOURCE_CONTACTS, BasicFilteredList.DATA_FIELD_CONTACTS_EMAIL | BasicFilteredList.DATA_FIELD_CONTACTS_NAME_FULL, BasicFilteredList.DATA_FIELD_CONTACTS_EMAIL, BasicFilteredList.DATA_FIELD_CONTACTS_NAME_FULL,

  • 1,

null); AutoCompleteField autoCompleteField = new AutoCompleteField(filterList); add(autoCompleteField);

Thursday, July 22, 2010

slide-41
SLIDE 41

Managing your Screen

Thursday, July 22, 2010

slide-42
SLIDE 42
  • FlowFieldManager

Thursday, July 22, 2010

slide-43
SLIDE 43
  • VerticalFieldManager
  • MainScreen is a

VerticalFieldManager

Thursday, July 22, 2010

slide-44
SLIDE 44
  • HorizontalFieldManager

Thursday, July 22, 2010

slide-45
SLIDE 45

HorizontalFieldManager buttons = new HorizontalFieldManager (Field.FIELD_HCENTER | Field.USE_ALL_WIDTH); buttons.add(new SimpleButton("Button 1")); buttons.add(new SimpleButton("Button 2")); add(buttons);

Thursday, July 22, 2010

slide-46
SLIDE 46
  • 5.0
  • GridLayoutManager
  • EyelidLayoutManager

Thursday, July 22, 2010

slide-47
SLIDE 47
  • TableLayoutManager
  • Works back to 4.3
  • Knowledge Base #DB-00783

Thursday, July 22, 2010

slide-48
SLIDE 48

_table = new TableLayoutManager(new int[] { TableLayoutManager.USE_PREFERRED_SIZE, TableLayoutManager.USE_PREFERRED_SIZE }, 0);

Thursday, July 22, 2010

slide-49
SLIDE 49
  • YourCustomManager
  • pixels
  • autofill
  • scrolling

Thursday, July 22, 2010

slide-50
SLIDE 50
  • query the screen size
  • Display.GetWidth

Thursday, July 22, 2010

slide-51
SLIDE 51
  • Buttons
  • you can figure out buttons
  • you click on them

Thursday, July 22, 2010

slide-52
SLIDE 52
  • Lists
  • You're pulling from a web api
  • I have lists of tasks

Thursday, July 22, 2010

slide-53
SLIDE 53
  • ListField Class
  • RichTextField

Thursday, July 22, 2010

slide-54
SLIDE 54
  • ListField
  • vector of items
  • small static class to read the vector
  • callbacks to update the list from another

thread

Thursday, July 22, 2010

slide-55
SLIDE 55

Feeling like a BB app

Thursday, July 22, 2010

slide-56
SLIDE 56

Menus

Thursday, July 22, 2010

slide-57
SLIDE 57
  • Users live in the menu
  • They expect to be able to trigger actions

Thursday, July 22, 2010

slide-58
SLIDE 58

private MenuItem _viewItem = new MenuItem("More Info", 110, 10) { public void run() { _infoScreen = new InfoScreen(); UiApplication.getUiApplication().pushScreen(_infoScreen); } };

Thursday, July 22, 2010

slide-59
SLIDE 59

Thursday, July 22, 2010

slide-60
SLIDE 60

Trackball

Thursday, July 22, 2010

slide-61
SLIDE 61

Trackpad (if you have a fancy new device)

Thursday, July 22, 2010

slide-62
SLIDE 62
  • Users have to scroll to get somewhere
  • (unless they're using a storm)
  • Don't make it hard for them

Thursday, July 22, 2010

slide-63
SLIDE 63

Thursday, July 22, 2010

slide-64
SLIDE 64

new LabelField("Stuff", LabelField.NON_FOCUSABLE | LabelField.READONLY

Thursday, July 22, 2010

slide-65
SLIDE 65

Networking

Thursday, July 22, 2010

slide-66
SLIDE 66

Netnotworking

Thursday, July 22, 2010

slide-67
SLIDE 67

(HttpConnection) Connector.open ("http://hiveminder.com"); (StreamConnection)Connector.open ("socket://hiveminder.com:993");

Thursday, July 22, 2010

slide-68
SLIDE 68
  • Heavy Corporate use
  • Sell control from the BES
  • wiping handsets
  • blocking access
  • pushing data/software

Thursday, July 22, 2010

slide-69
SLIDE 69
  • All your data passes through the
  • BES
  • MDS

Thursday, July 22, 2010

slide-70
SLIDE 70
  • BIS
  • BIS-B

Thursday, July 22, 2010

slide-71
SLIDE 71
  • "http://hiveminder.com;deviceside=true"
  • "http://hiveminder.com;deviceside=false"

Thursday, July 22, 2010

slide-72
SLIDE 72
  • direct tcp
  • WAP2

Thursday, July 22, 2010

slide-73
SLIDE 73

If you're not using MDS/BIS-B, RIM suggests you test data access on every network you're going to support.

Thursday, July 22, 2010

slide-74
SLIDE 74

Good luck with that

Thursday, July 22, 2010

slide-75
SLIDE 75

Split-pipe

Thursday, July 22, 2010

slide-76
SLIDE 76
  • APN info for Direct TCP/IP

"deviceside=true; apn=internet.com; tunnelauthusername=user165; tunnelauthpassword=user165password"

Thursday, July 22, 2010

slide-77
SLIDE 77
  • ServiceBooks api
  • WAP2 automated
  • ";ConnectionUID=uid"

Thursday, July 22, 2010

slide-78
SLIDE 78
  • Wifi
  • ";interface=wifi"

Thursday, July 22, 2010

slide-79
SLIDE 79
  • You also need one of these

private class ConnectionThread extends Thread

Thursday, July 22, 2010

slide-80
SLIDE 80
  • CoverageInfo class
  • Lets you ask about what network are

available, so you can fall back to ServiceBooks to get info if you need it.

  • Can tell you about wifi availability
  • Best availability is 4.5 or later, but you have

it in 4.2/4.3 also

Thursday, July 22, 2010

slide-81
SLIDE 81

BES Admins can still block your service

Thursday, July 22, 2010

slide-82
SLIDE 82

Thursday, July 22, 2010

slide-83
SLIDE 83

Parsing

Thursday, July 22, 2010

slide-84
SLIDE 84
  • RIM provides SAXParser
  • javax.*.xml if you want

Thursday, July 22, 2010

slide-85
SLIDE 85

String serverResponse = XMLString; SAXParserFactory factory = SAXParserFactory.newInstance(); SAXParser saxParser = factory.newSAXParser(); InputStream in = new ByteArrayInputStream(XMLString.getBytes()); InputSource inputSource = new InputSource(in); saxParser.parse(in, new HiveminderXMLHandler()); static class HiveminderXMLHandler extends DefaultHandler { public void startElement(String uri, String name, String qName, Attributes atts){ // track current element } public void endElement(String uri, String name, String qName){ // you have all the data } public void characters(char buf[],int offset,int len) throws SAXException { // read in your data } }

Thursday, July 22, 2010

slide-86
SLIDE 86
  • json
  • there is no built in library
  • no generics, so something that uses one
  • f the android protocol buffer libraries is
  • ut

Thursday, July 22, 2010

slide-87
SLIDE 87
  • If you google, you'll find this url
  • http://www.json.org/java/org.json.me.zip

Thursday, July 22, 2010

slide-88
SLIDE 88
  • https://edge.launchpad.net/j2me-json
  • works, went with xml for my uses

Thursday, July 22, 2010

slide-89
SLIDE 89

A brief interlude Code Signing

Thursday, July 22, 2010

slide-90
SLIDE 90
  • browser
  • registering as a plugin
  • user data
  • messaging
  • persistent storage

Thursday, July 22, 2010

slide-91
SLIDE 91
  • pay RIM your $25
  • Install Code Signer
  • Eclipse can sign .cod when building

Thursday, July 22, 2010

slide-92
SLIDE 92

Persistence

Thursday, July 22, 2010

slide-93
SLIDE 93
  • 5.0
  • SQLite
  • all versions
  • implements Persistable

Thursday, July 22, 2010

slide-94
SLIDE 94
  • implements Persistable
  • most often, storing a vector
  • you give your store a unique id, collisions

can happen

  • over upgrades, make sure you can read

the old data

Thursday, July 22, 2010

slide-95
SLIDE 95

Integration

Thursday, July 22, 2010

slide-96
SLIDE 96

Thursday, July 22, 2010

slide-97
SLIDE 97

public static void main(String[] args) { boolean startup = false; for (int i=0; i<args.length; ++i) { if (args[i].startsWith("init")) { startup = true; } } if (startup) { // stuff FolderListener into RuntimeStore } else { // start gui and read from RuntimeStore } }

Thursday, July 22, 2010

slide-98
SLIDE 98
  • implements FolderListener
  • RuntimeStore.getRuntimeStore();
  • Object obj = store.get(0xDEADBEEF);

Thursday, July 22, 2010

slide-99
SLIDE 99
  • Adding yourself to foreign apps

Thursday, July 22, 2010

slide-100
SLIDE 100

ApplicationMenuItem mi = new ApplicationMenuItem(placement) { public Object run(Object context) { } public String toString() { return "Assign task to this user"; } }; ApplicationMenuItemRepository mir = ApplicationMenuItemRepository.getInstance(); mir.addMenuItem(ApplicationMenuItemRepository.MENUITEM_ADDRESSCARD_VIEW, ami);

Thursday, July 22, 2010

slide-101
SLIDE 101

Distribution

Thursday, July 22, 2010

slide-102
SLIDE 102
  • JavaLoader
  • Desktop Manager
  • OTA Download
  • IE plugin
  • AppWorld
  • 17 competing markets

Thursday, July 22, 2010

slide-103
SLIDE 103

Questions?

  • http://jibsheet.com/talks/oscon2010.pdf

Kevin Falcone kevin@jibsheet.com

Thursday, July 22, 2010