Presentation is loading. Please wait.

Presentation is loading. Please wait.

PROG 38448 Mobile Java Application Development PROG 38448 Mobile Java Application Development BlackBerry App Lifecycle Java ME API.

Similar presentations


Presentation on theme: "PROG 38448 Mobile Java Application Development PROG 38448 Mobile Java Application Development BlackBerry App Lifecycle Java ME API."— Presentation transcript:

1 PROG 38448 Mobile Java Application Development PROG 38448 Mobile Java Application Development BlackBerry App Lifecycle Java ME API

2 10/9/2015Wendi Jollymore, ACES2 BlackBerry App Life Cycle 1. Application Starts Three ways to start an app: User clicks app icon App starts automatically on startup or reboot App is started by another app Starting point in your application class is main() method

3 10/9/2015Wendi Jollymore, ACES3 BlackBerry App Life Cycle 2. Application Object Is Created Triggered in the main() method You instantiate your application class that extends UiApplication Application classes with a Ui must extend UiApplication class Can only have one UiApplication instance for any application Otherwise RuntimeException is thrown.

4 10/9/2015Wendi Jollymore, ACES4 BlackBerry App Life Cycle 3. Event thread is started main() is the main thread or process that’s running Do anything you need to do here before you pass control to BB O/S enterEventDispatcher() method call Takes control of the main thread Draws the main screen and listens for events Won’t return, so if you need something else done in main(), do it first

5 10/9/2015Wendi Jollymore, ACES5 BlackBerry App Life Cycle 4. Events are processed User events triggered by input from trackball, touch screen, keyboard, etc Other events 5. Application Exits When the last screen is removed from the stack. Avoid System.exit() !! Close all screens until the last screen is closed. Proper clean up of all application state

6 10/9/2015Wendi Jollymore, ACES6 What is the API? Application Program Interface The collection and definition of building blocks available in a language Descriptions of classes and their public methods http://en.wikipedia.org/wiki/Api Where to read the API docs? http://www.blackberry.com/developers/docs/ 6.0.0api/index.html Go to any JDE folder and select BlackBerry JDE API Reference

7 10/9/2015Wendi Jollymore, ACES7 Java ME API Java ME – Micro Edition For developing mobile apps Runs on custom JVM for BlackBerry BlackBerry Java Virtual Machine MIDP 2.0 Standard– Mobile Information Device Profile http://www.webopedia.com/TERM/M/ MIDP.html Part of Java ME API used for various mobile devices (not just for RIM) Contains APIs for persistent storage, user interface, networking

8 10/9/2015Wendi Jollymore, ACES8 Java ME API CLDC – Connected Limited Device Configuration http://www.webopedia.com/TERM/C/C LDC.html A specification for a stripped down virtual machine For devices with very limited memory Contains minimalist versions of java.lang, java.util, java.io Contains java.microedition.io for network connections

9 10/9/2015Wendi Jollymore, ACES9 Java ME API Other API Extensions specific to BlackBerry devices User Interface Persistent Data Storage Networking Event Listeners Application Integration Additional utilities for encryption, compression, location-based services, etc.

10 10/9/2015Wendi Jollymore, ACES10 Using API to Create App Simplest: Start with two classes An application class The main application where it all starts Extends UiApplication class Three main tasks to perform: Create an instance of the app Create main screen and push onto display stack Start the event dispatch thread

11 10/9/2015Wendi Jollymore, ACES11 Using API to Create App Simplest: Start with two classes (continued) A screen class A visible display Extends MainScreen class Could have components, images, user input, etc Components = Fields net.rim.device.api.ui.Field Layout = Managers net.rim.device.api.ui.Manager

12 10/9/2015Wendi Jollymore, ACES12 UiApplication Class net.rim.device.api.ui.UiApplication Child of Application class A non-gui program would extend this Base class for all UI applications Contains a screen stack Only top screen is ever visible pushScreen(screen) adds a screen to the stack Lays out and prints the screen object A screen can only be pushed onto the stack once, or exception occurs

13 10/9/2015Wendi Jollymore, ACES13 UiApplication Class public class MyApp extends UiApplication { public MyApp() { MyScreen scr = new MyScreen(); pushScreen(scr); } //... }

14 10/9/2015Wendi Jollymore, ACES14 UiApplication Class Event dispatcher thread enterEventDispatcher() called on your application class Takes control of main thread Handles all drawing and event- handling Never returns; ends when application ends Call this in the application’s main() method

15 10/9/2015Wendi Jollymore, ACES15 UiApplication Class public class MyApp extends UiApplication { public MyApp() { MyScreen scr = new MyScreen(); pushScreen(scr); } public static void main(String[] args) { MyApp app = new MyApp(); app.enterEventDispatcher(); } }

16 10/9/2015Wendi Jollymore, ACES16 MainScreen Class net.rim.device.api.ui.container. MainScreen Child of Screen/FullScreen class Has a VerticalFieldManager, title area, default menu, etc In the MainScreen constructor is where you’d create and lay out your main UI

17 10/9/2015Wendi Jollymore, ACES17 MainScreen Class public class MyScreen extends MainScreen { public MyScreen() { LabelField label = new LabelField(“Hello!"); add(label); LabelField title = new LabelField("Java ME"); this.setTitle(title); } }

18 10/9/2015Wendi Jollymore, ACES18 Hierarchy It’s interesting to note the inheritance hierarchy of these classes: Object Field ScrollView Manager Screen

19 10/9/2015Wendi Jollymore, ACES19 Exercises and Homework Exercise: Do the exercise in the Lesson 2 notes For next class: Read Chapter 4 of Beginning BlackBerry


Download ppt "PROG 38448 Mobile Java Application Development PROG 38448 Mobile Java Application Development BlackBerry App Lifecycle Java ME API."

Similar presentations


Ads by Google