This webinar presentation provides an overview of how to port various types of Java™ applications for BlackBerry OS to the Series 40 platform. Michael Samarin of Futurice walks you through the basic porting tasks involved and shows you how to map BlackBerry APIs to corresponding Series 40 APIs.
2. Porting Considerations
» Same development platform Java ME on Series 40 and
BlackBerry (up to OS 7.1).
» Same Java dialect makes porting easier.
» Midlets based on CLDC 1.1, MIDP 2.0 and common JSRs can be
packaged to run without changes on both BlackBerry and
Series 40.
» Canvas based 2D games without BlackBerry platform services
can be just recompiled for Series 40, of course taking screen
sizes and graphical assets into consideration.
3. General Porting Challenges I
» Most BlackBerry “Business” apps are using RIMs
application framework, built on top of Java ME and
utilizing platform integration features.
» User interface based on UIApplication frameworks
must be re-written.
» Developers should recognize the major differences
between the platforms: BlackBerry devices are full
smartphones with multitasking capabilities, and Series
40 devices are feature phones with much more limited
resources and device capabilities.
4. General Porting Challenges II
» BlackBerry platform provides deep integration facilities with
device messaging, telephony and PIM.
» Series 40 provides only JSR-75, FileConnection and PIM API
which gives access only to file system and contacts/calendar
entries.
5. Memory Considerations
» On Series 40 Memory Limitations:
› Application JAR file size can’t exceed 2 MB.
› Java Heap Size is 2 or 4 MB.
› Use Nokia Device Matrix for checking:
http://www.developer.nokia.com/Devices/Device_specifications/
» Brings challenging decisions, especially to visually rich games,
with many bundled graphical resources.
» Option: post-download of needed resources and caching in
RMS.
6. Portability of App Types
2D Games Excellent portability, source code-level compatibility. 2D game
development on BlackBerry and Series 40 uses the same Java ME
APIs from the javax.microedition.lcdui.game package. For
devices with similar input types (touch, non-touch) porting would be
possible by simply recompiling and repackaging. However, the main
focus for porting will be the optimization of graphical assets to
smaller screen sizes, adaptation of different touch gestures, and
adjusting to Series 40 memory requirements.
3D Games Generally portable. BlackBerry 3D gaming uses Java interfaces for
OpenGL ES. Series 40 doesn’t support OpenGL ES but it features an
excellent implementation of Mobile 3D Graphics (JSR-184 or M3G).
This JSR is significantly simpler and optimized for low memory
footprint but it is far from being primitive and it is a real 3D
rendering engine with a special immediate mode, which is
ideologically very similar to OpenGL. Similarly as in 2D gaming,
Series 40 memory requirements impose challenges for textures and
graphical assets.
7. Portability of App Types
Social Networking Applications with OAuth authentication are not portable as
Java apps because the Series 40 platform doesn’t support
embeddable web view and the custom Java ME
implementation of OAuth appears to be challenging. The
Series 40 platform doesn’t support multitasking and
background execution, so implementing messaging
notifications when the application is not running is not
possible. However, if background functionality is not needed
and if the social networking app is using custom
authentication schemes or private APIs for well-known
networks, then it is generally portable. Developers of such
apps should consider exploring Nokia Web Apps, where at
least the OAuth issue can be resolved.
SMS, MMS, and Generally portable. BlackBerry and Series 40 both feature the
Bluetooth Wireless Messaging API (JSR-205) and Java APIs for Bluetooth (JSR-
Messaging 82). Some parts can be compatible on the source code level with the
correct level of abstraction from the UI.
8. Portability of App Types
Telephony and Generally not portable. The Series 40 platform doesn’t
platform support integration with telephony and other these
messaging types of services for 3rd party developers. Applications
services for VoIP, Caller ID, Tethering, platform email, and Social
Networking apps’ integrations are not feasible on Series
40.
Video, audio, and Generally not portable. The Series 40 platform doesn’t
image processing provide APIs for media parsing, recompressing, and
image processing. It is also related to memory
restrictions (2 or 4 MB Java Heap) imposed on 3rd party
applications.
9. Portability of App Types
Photography and Generally portable with Advanced Multimedia
camera Supplements APIs (JSR-234) which is also supported on
BlackBerry with source code level compatibility. Image
filtering and processing full resolution images is not
possible due to memory restrictions.
News readers, Generally portable. UI redesign and optimization of
book readers, graphical assets is required. The Series 40 platform
business, finance, doesn’t support embeddable web view and book /
comics, magazine reader apps should implement custom text
magazines rendering with LCDUI components or Canvas. Comics
and magazine readers should take special precautions
regarding memory limitations.
10. Portability of App Types
Media playback Generally portable with Mobile Media API (JSR-135).
and streaming Simple audio / video playback and streaming is possible
and might be compatible on source code level.
Redesign is required for background audio streaming
apps, which are not supported on Series 40.
Maps and Generally portable with Nokia Maps API for Series 40,
location which provides also search, geocoding, reverse
geocoding, and routing functionality. Series 40 devices
are not equipped with GPS, so Cell ID-based location or
an external GPS device with Bluetooth connection is
needed.
11. Most Interesting for porting
QWERTY Devices
BlackBerry Bold 9900 BlackBerry Curve 9350 Nokia Asha 303 Nokia Asha 302
640 x 480 480 x 360 240 x 320 320 x 240
QWERTY and Capacitive QWERTY and Capacitive
QWERTY QWERTY
Touch Screen Touch Screen
ROM/RAM ROM/RAM ROM/RAM
ROM/RAM 8GB/768MB,
512MB/512MB, 32 GB 256MB/128MB, 32 GB 256MB/128MB, 32 GB
32 GB Micro SD
Micro SD Micro SD Micro SD
12. Most Interesting for porting
Full Touch Devices
BlackBerry Torch BlackBerry Torch
Nokia Asha 311 Nokia Asha 305/306 Nokia Asha 308/309
9860 9810
800 x 480 640 x 480 240 x 400 240 x 400 240 x 400
QWERTY and Capacitive Touch Resistive Touch Capacitive Touch
Capacitive Touch
Capacitive Touch Screen, Multipoint- Screen, Multipoint- Screen, Multipoint-
Screen
Screen touch (5 points) touch (2 points) touch
ROM/RAM ROM/RAM ROM/RAM ROM/RAM ROM/RAM
4GB/768MB, 32 GB 8GB/768MB, 32 GB 256MB/128MB, 32 64MB/32MB, 32 GB 128MB/64MB, 32
Micro SD Micro SD GB Micro SD Micro SD GB Micro SD
13. User Interface Porting Options
» A typical BlackBerry application with a standard UI (based on
net.rim.device.api.ui)
» On Series 40, most standard option is LCDUI, gives platform’s
Look & Feel, support for device Themes.
» Alternative options is LWUIT library, recently optimized for
Series 40, full flexible UI with Java Swing-alike architecture.
14. UI Model Differences
BlackBerry Series 40
UIApplication LCDUI
New Current Displayable 1
Screen Screen
Displayable 2 Current
Switch
Push Pop Displayable
Displayable 3
Stack …
Screen 1 Displayable N
Screen 2
Screen 3
…
Screen N In LCDUI on Series 40 you can switch between screens
directly. In addition to LCDUI, Nokia provides Series 40-
The screens of a BlackBerry application specific extensions known as the Nokia UI API. These
(UiApplication) are managed according APIs enhance MIDP with a functionality related to
to the stack model - you can push your touch screen gestures, canvas drawing, text editing,
application screens into the stack and and kinetic scrolling.
the screen on top of the stack is what is
visible to the user.
15. Simple Common UI Porting Sample
» Illustration of typical steps
for porting UIApplication
based UI.
Main Screen Detailed Screen
» Standard UI with master- Item 1
detailed screens. Item 2
Item 2
» List component with Item 3
several items on main …
screen. Item N Back
» Selected text from
previous screen on detailed
screen.
16. UI Differences - BlackBerry: Main Application Class
import net.rim.device.api.ui.UiApplication;
public class App extends UiApplication
{
public static void main(String[] args)
{
App theApp = new App();
theApp.enterEventDispatcher();
}
public App()
{
pushScreen(new AppMainScreen());
}
}
In the main method we instantiate App class and by using UiApplication
method pushScreen() in the constructor of the application class, we
create and display main applications screen represented by
AppMainScreen class.
17. UI Differences - BlackBerry: Main Screen Class
import net.rim.device.api.command.Command; Both application screens
import net.rim.device.api.command.CommandHandler;
import net.rim.device.api.command.ReadOnlyCommandMetadata;
AppMainScreen and SimpleScreen are
import net.rim.device.api.ui.UiApplication; extending MainScreen class which is
import net.rim.device.api.ui.component.table.SimpleList; commonly used screen container that
import net.rim.device.api.ui.container.MainScreen;
inherits all default behavior of the
public final class AppMainScreen extends MainScreen standard BlackBerry application
{ screens. Main screen displays list
private SimpleList listField;
private SimpleScreen simpleScreen;
component based on SimpleList class.
Adding list component to the screen
public AppMainScreen() { and filling it up with items is
super( MainScreen.NO_VERTICAL_SCROLL);
setTitle("Simple List Demo");
straightforward operation. One
interesting aspect of working with list
listField = new SimpleList(getMainManager()); components is tracking selection of
listField.add("Helsinki");
listField.add("Tampere");
item. Since there is wide variety of
listField.add("London"); BlackBerry devices with touch and
listField.add("Paris"); keyboard based input, traditional
listField.add("Berlin");
approach is to use both explicit
listField.setCommand(new Command(new CommandHandler(){ mechanisms for tracking events.
However, the most effective way
public void execute(ReadOnlyCommandMetadata metadata, Object context)
{
which at the same time significantly
showSimpleScreen((String)listField.getModel().getRow(listField.getFocusRow())); minimizes code usage is to use
} Command class with dedicated
}));
command handler, like in the example
} above.
private void showSimpleScreen(String message){
if (simpleScreen == null){
Once it’s been detected, that user
simpleScreen = new SimpleScreen(); selected item, method
} showSimpleScreen is called with string
simpleScreen.setText(message);
UiApplication.getUiApplication().pushScreen(simpleScreen);
content of the selection. At this point,
} there is a need for making check if our
} next screen class has been already
created, passing string argument and
pushing screen to the visible UI stack.
18. UI Differences - BlackBerry: Detailed Screen Class
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.MainScreen;
public class SimpleScreen extends MainScreen {
LabelField labelField;
public SimpleScreen() {
super(MainScreen.VERTICAL_SCROLL | MainScreen.VERTICAL_SCROLLBAR);
setTitle("Simple Screen");
labelField = new LabelField("Some text", LabelField.FIELD_HCENTER |LabelField.FIELD_VCENTER);
add(labelField);
}
public void setText(String text){
labelField.setText(text);
}
}
Actual code for making detailed screen is simple and features only custom method for providing text content for
the label component.
22. Live Demo Session
BlackBerry SimpleList
» If you are watching these slides on SlideShare, next part is live coding
demonstration. Full recording of the live session can be found at Nokia
Developer website:
» http://www.developer.nokia.com/Resources/Multimedia/Webinars.xhtml
23. Live Demo Session
Series 40 SimpleList
» If you are watching these slides on SlideShare, next part is live coding
demonstration. Full recording of the live session can be found at Nokia
Developer website:
» http://www.developer.nokia.com/Resources/Multimedia/Webinars.xhtml
24. Live Demo Session
BlackBerry SimpleListMap
» If you are watching these slides on SlideShare, next part is live coding
demonstration. Full recording of the live session can be found at Nokia
Developer website:
» http://www.developer.nokia.com/Resources/Multimedia/Webinars.xhtml
25. Live Demo Session
Series 40 SimpleListMap
» If you are watching these slides on SlideShare, next part is live coding
demonstration. Full recording of the live session can be found at Nokia
Developer website:
» http://www.developer.nokia.com/Resources/Multimedia/Webinars.xhtml
26. Live Demo Session
BlackBerry / Series 40 Midlet
» If you are watching these slides on SlideShare, next part is live coding
demonstration. Full recording of the live session can be found at Nokia
Developer website:
» http://www.developer.nokia.com/Resources/Multimedia/Webinars.xhtml