ch.aplu.gidlet
Class Gidlet

java.lang.Object
  extended by javax.microedition.midlet.MIDlet
      extended by ch.aplu.gidlet.Gidlet
All Implemented Interfaces:
KeyListener, java.lang.Runnable

public abstract class Gidlet
extends javax.microedition.midlet.MIDlet
implements KeyListener, java.lang.Runnable

Abstract helper class derived from MIDlet to provide functionalities for starting and stopping the application. Typically the application class extends this class. To simplify the application programming, some useful methods and static variables are declared, so that no explicit class or instance identifier is needed.

The platform's call of startApp() will create a separate thread (called "main-thread") that calls main(). The application class should override main() and perform all operations in the main() method.

main() must terminate so that the main-thread stops running.

If an endless loop in main() is needed, test with isExiting() whether the Exit soft button has been hit. If the program blocks in the loop because of waitOk(), readXXX(), showMessage(), main() will terminate immediately when the Exit soft button is hit. In this case an endless loop with while (true) is permitted.

Keep in mind that before main() runs, the environment is not fully initialized. Therefore do not create visible GUI elements as instance variables. If needed you may declare them as instance variable and create them in main(). The standard Gidlet GUI elements starting with the letter 'M' (MForm, MConsole, etc.) may be created as instance variable because there is an internal mechanism that defers their initilization until main() runs.

When the platform requests the Gidlet to terminate by calling destroyApp(), the Gidlet will terminate by calling doExit() that calls notifyDestroyed(), if neither destroyApp() nor doExit() is overridden.

Before calling main() a special thread will be started in order disable the the screen saver from shading the screen. If the screen saver should remain active, declare a constructor and call enableScreenSaver(true).


Nested Class Summary
 class Gidlet.HttpGetter
          Class that creates a thread to transfer data using the HTTP GET command.
 class Gidlet.MMSReader
          Class that creates a MMS server thread based on the Wireless Messaging API (WMA).
 class Gidlet.SMSReader
          Class that creates a SMS server thread based on the Wireless Messaging API (WMA).
 
Field Summary
static int BLACK
          The color black.
static int BLUE
          The color blue.
static int CYAN
          The color cyan.
static int DARKGRAY
          The color darkgray.
static javax.microedition.lcdui.Display display
          The current MIDlet's display.
protected  java.util.Vector displays
          List of all displays created before main() is called.
static int DOUBLE_VALIDATE
          Validation type "Garantee to be a double"
static int DOWN_PRESSED
          Same as GameCanvas.DOWN_PRESSED.
static int FIRE_PRESSED
          Same as GameCanvas.FIRE_PRESSED.
static int GAME_A_PRESSED
          Same as GameCanvas.GAME_A_PRESSED.
static int GAME_B_PRESSED
          Same as GameCanvas.GAME_B_PRESSED.
static int GAME_C_PRESSED
          Same as GameCanvas.GAME_C_PRESSED.
static int GAME_D_PRESSED
          Same as GameCanvas.GAME_D_PRESSED.
static int GRAY
          The color gray.
static int GREEN
          The color green.
static int INT_VALIDATE
          Validation type "Garantee to be an integer"
static int LEFT_PRESSED
          Same as GameCanvas.LEFT_PRESSED.
static int LIGHTGRAY
          The color lightgray.
static int LONG_VALIDATE
          Validation type "Garantee to be a long"
static int MAGENTA
          The color magenta.
static Gidlet myGidlet
          A reference to the current gidlet.
static int NONE_VALIDATE
          Validation type "No validation"
static int ORANGE
          The color orange.
static int PINK
          The color pink.
static int RED
          The color red.
static int RIGHT_PRESSED
          Same as GameCanvas.RIGHT_PRESSED.
protected  java.util.Vector turtles
          List of all turtles created before main() is called.
static int UP_PRESSED
          Same as GameCanvas.UP_PRESSED.
static int WHITE
          The color white.
static int YELLOW
          The color yellow.
 
Constructor Summary
Gidlet()
          Constructs a Gidlet instance and perform a few initializations.
 
Method Summary
static void beep(int type)
          Plays a system sound of given type.
protected  void closeTimedMessage()
          Closes a timed message box before timeout expires.
static void delay(int time)
          Delays execution for the given amount of time (in ms).
protected  void destroyApp(boolean b)
          Called when the platform requests to terminate the program.
protected  void doExit()
          Terminates the application by calling wakeUp() and notifyDestroyed().
protected  void doOk()
          Empty.
protected  void doPause()
          Empty.
static boolean getDebug()
          Returns true if debug information is turned on.
static Gidlet getGidlet()
          Returns a reference to the current gidlet instance.
static javax.microedition.lcdui.Image getImage(java.lang.String imageUrl)
          Loads image from given resource and returns it's Image reference.
 javax.microedition.lcdui.Image getImageHttp(java.lang.String imageUri, int timeout)
          Loads image from given HTTP uri and returns it's Image reference.
static byte[] getResource(java.lang.String resourceUrl)
          Loads resource into byte array.
static javax.microedition.lcdui.game.Sprite getSprite(java.lang.String imageUrl)
          Loads image from given resource and returns it's Sprite reference.
static javax.microedition.lcdui.game.Sprite getSprite(java.lang.String imageUrl, int frameWidth, int frameHeight)
          Loads image from given resource with given frameWidth, frameHeight and returns it's Sprite reference.
static java.lang.Thread getThread()
          Returns the main thread.
static long getTime()
          Gets timer's time (in ms).
static java.lang.String getVersion()
          Returns version information of Gidlet framework.
protected  void internalNotifyHttpResponse(byte[] data, int code)
           
static boolean isEmulator()
          Returns true, if the application runs in the emulator, otherwise false.
static boolean isExiting()
          Returns true, if the Exit soft button is hit in a readXXX(), showMessage() or showTimeMessage() method.
static boolean isSleeping()
          Returns true, if putSleep() was called and still waiting for wakeUp() or timeout.
 void keyPressed(int keyCode)
          Empty implementation of KeyListener.keyPressed().
 void keyReleased(int keyCode)
          Empty implementation of KeyListener.keyReleased().
 void keyRepeated(int keyCode)
          Empty implementation of KeyListener.keyRepeated().
abstract  void main()
          Abstract declaration, must be overridden by derived class.
protected  void messageTimeout()
          Will be called when the timeout of the timed message expires.
 void notifyHttpResponse(byte[] response, int httpCode)
          Empty callback method triggered by HttpReader when the transfer due to the HTTP GET command issued by the HttpGetter constructor terminates or when an error occured.
 void notifyHttpResponse(java.lang.String response, int httpCode)
          Empty callback method triggered by HttpReader when the transfer due to the HTTP GET command issued by the HttpGetter constructor terminates or when an error occured.
 void notifyIncomingMMS(javax.wireless.messaging.MultipartMessage mpm)
          Empty callback method triggered by the MMSReader thread when a MMS is received.
 void notifyIncomingSMS(javax.wireless.messaging.TextMessage msg)
          Empty callback method triggered by the SMSReader thread when a SMS is received.
 void notifyOutgoingMMS(int status)
          Empty callback method triggered by the sendMMS() and sendMMSMail() thread when it terminates.
 void notifyPlayerUpdate(java.lang.String event, java.lang.Object eventData)
          Empty callback method triggered by the PlayerListener when the state of the Player is updated.
protected  void pauseApp()
          Called when the platform requests to pause the program.
static boolean putSleep()
          Same as putSleep(int timeout) with timeout = 0 (timeout disalbed).
static boolean putSleep(int timeout)
          Puts the current thread in a wait state until wakeUp() is called or timeout (in ms) expires.
protected static double readDouble(java.lang.String prompt)
          Shows a simple form with an input field with the given prompt message and no initial value.
protected static double readDouble(java.lang.String prompt, double init)
          Shows a simple form with an input field with the given prompt message, and given initial value.
 java.lang.String readFile(java.lang.String fileUrl)
          Reads content of a text file from a given url.
protected static int readInt(java.lang.String prompt)
          Shows a simple form with an input field with the given prompt message and no initial value.
protected static int readInt(java.lang.String prompt, int init)
          Shows a simple form with an input field with the given prompt message and given initial value.
protected static long readLong(java.lang.String prompt)
          Shows a simple form with an input field with the given prompt message and no initial value.
protected static long readLong(java.lang.String prompt, long init)
          Shows a simple form with an input field with the given prompt message and given initial value.
protected static java.lang.String readString(java.lang.String prompt)
          Shows a simple form with an input field with the given prompt message and no initial value.
protected static java.lang.String readString(java.lang.String prompt, java.lang.String init)
          Shows a simple form with an input field with the given prompt message, and given initial value.
static java.lang.String readTextResource(java.lang.String fileUrl)
          Reads and returns text from a textfile with given URL.
 void run()
          Gidlet's run-method implementation.
protected static void sendMMS(java.lang.String phonenumber, java.lang.String appId, java.lang.String subject, javax.wireless.messaging.MessagePart[] parts)
          Sends a MMS to given phone number with given application identifier, subject, and message parts.
protected static void sendMMS(java.lang.String phonenumber, java.lang.String appId, java.lang.String subject, javax.wireless.messaging.MessagePart[] parts, java.lang.String startContentId)
          Sends a MMS to given phone number with given application identifier, subject, message parts and startContentId.
protected static void sendMMSMail(java.lang.String recipient, java.lang.String subject, java.lang.String message)
          Sends an e-mail via MMS with given recipient's e-mail address, subject and message.
protected static int sendSMS(java.lang.String phonenumber, int portnumber, java.lang.String text)
          Sends a SMS with given text to given phone and SMS port number.
protected static int sendSMS(java.lang.String phonenumber, java.lang.String text)
          Sends a SMS with given text to given phone number (and no SMS port number).
static void setDebug(boolean debug)
          Turns on/off debug information on System.out (default: off).
protected  void showDebug(java.lang.String msg)
          Displays given debug message on System.out, when debugging is enabled by setDebug(true).
static void showMessage(java.lang.String msg)
          Shows a simple form with an output field that contains the given message.
static void showMessage(java.lang.String msg, boolean restore)
          Shows a simple form with an output field that contains the given message.
protected  void showTimedMessage(java.lang.String msg, int duration)
          Shows a simple form during the given duration (in ms) with an output field that contains the given message.
static java.lang.String[] split(java.lang.String s, java.lang.String separator)
          Splits given string with given separator string into multiple strings.
protected  void startApp()
          Implementation of MIDlet.startApp().
static void startTimer()
          Starts a timer or restart it by setting its time to zero.
protected static void waitOk()
          Waits until the OK soft button is hit.
protected static void waitOk(boolean addOkButton)
          Waits until a OK soft button is hit.
static void wakeUp()
          Wakes up the waiting thread.
 
Methods inherited from class javax.microedition.midlet.MIDlet
checkPermission, getAppProperty, notifyDestroyed, notifyPaused, platformRequest, resumeRequest
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

displays

protected java.util.Vector displays
List of all displays created before main() is called.


turtles

protected java.util.Vector turtles
List of all turtles created before main() is called.


display

public static javax.microedition.lcdui.Display display
The current MIDlet's display.


myGidlet

public static Gidlet myGidlet
A reference to the current gidlet.


BLACK

public static final int BLACK
The color black.

See Also:
Constant Field Values

BLUE

public static final int BLUE
The color blue.

See Also:
Constant Field Values

CYAN

public static final int CYAN
The color cyan.

See Also:
Constant Field Values

DARKGRAY

public static final int DARKGRAY
The color darkgray.

See Also:
Constant Field Values

GRAY

public static final int GRAY
The color gray.

See Also:
Constant Field Values

GREEN

public static final int GREEN
The color green.

See Also:
Constant Field Values

LIGHTGRAY

public static final int LIGHTGRAY
The color lightgray.

See Also:
Constant Field Values

MAGENTA

public static final int MAGENTA
The color magenta.

See Also:
Constant Field Values

ORANGE

public static final int ORANGE
The color orange.

See Also:
Constant Field Values

PINK

public static final int PINK
The color pink.

See Also:
Constant Field Values

RED

public static final int RED
The color red.

See Also:
Constant Field Values

WHITE

public static final int WHITE
The color white.

See Also:
Constant Field Values

YELLOW

public static final int YELLOW
The color yellow.

See Also:
Constant Field Values

NONE_VALIDATE

public static final int NONE_VALIDATE
Validation type "No validation"

See Also:
Constant Field Values

INT_VALIDATE

public static final int INT_VALIDATE
Validation type "Garantee to be an integer"

See Also:
Constant Field Values

LONG_VALIDATE

public static final int LONG_VALIDATE
Validation type "Garantee to be a long"

See Also:
Constant Field Values

DOUBLE_VALIDATE

public static final int DOUBLE_VALIDATE
Validation type "Garantee to be a double"

See Also:
Constant Field Values

FIRE_PRESSED

public static final int FIRE_PRESSED
Same as GameCanvas.FIRE_PRESSED.

See Also:
Constant Field Values

GAME_A_PRESSED

public static final int GAME_A_PRESSED
Same as GameCanvas.GAME_A_PRESSED.

See Also:
Constant Field Values

GAME_B_PRESSED

public static final int GAME_B_PRESSED
Same as GameCanvas.GAME_B_PRESSED.

See Also:
Constant Field Values

GAME_C_PRESSED

public static final int GAME_C_PRESSED
Same as GameCanvas.GAME_C_PRESSED.

See Also:
Constant Field Values

GAME_D_PRESSED

public static final int GAME_D_PRESSED
Same as GameCanvas.GAME_D_PRESSED.

See Also:
Constant Field Values

LEFT_PRESSED

public static final int LEFT_PRESSED
Same as GameCanvas.LEFT_PRESSED.

See Also:
Constant Field Values

RIGHT_PRESSED

public static final int RIGHT_PRESSED
Same as GameCanvas.RIGHT_PRESSED.

See Also:
Constant Field Values

UP_PRESSED

public static final int UP_PRESSED
Same as GameCanvas.UP_PRESSED.

See Also:
Constant Field Values

DOWN_PRESSED

public static final int DOWN_PRESSED
Same as GameCanvas.DOWN_PRESSED.

See Also:
Constant Field Values
Constructor Detail

Gidlet

public Gidlet()
Constructs a Gidlet instance and perform a few initializations.

Method Detail

startApp

protected void startApp()
Implementation of MIDlet.startApp(). If called the first time, create a new thread and run main(). If called after a pause, the display stored at this is moment is reshown.

Specified by:
startApp in class javax.microedition.midlet.MIDlet

getThread

public static java.lang.Thread getThread()
Returns the main thread.


main

public abstract void main()
Abstract declaration, must be overridden by derived class.


pauseApp

protected void pauseApp()
Called when the platform requests to pause the program. Will call doPause(), which is empty but may be overriden by a user's callback.

Specified by:
pauseApp in class javax.microedition.midlet.MIDlet

destroyApp

protected void destroyApp(boolean b)
Called when the platform requests to terminate the program. Will call doExit(), which calls notifyDestroyed(), if not overriden by a user's callback.

Specified by:
destroyApp in class javax.microedition.midlet.MIDlet

keyPressed

public void keyPressed(int keyCode)
Empty implementation of KeyListener.keyPressed().

Specified by:
keyPressed in interface KeyListener

keyReleased

public void keyReleased(int keyCode)
Empty implementation of KeyListener.keyReleased().

Specified by:
keyReleased in interface KeyListener

keyRepeated

public void keyRepeated(int keyCode)
Empty implementation of KeyListener.keyRepeated().

Specified by:
keyRepeated in interface KeyListener

run

public void run()
Gidlet's run-method implementation. Do not override.

Specified by:
run in interface java.lang.Runnable

doExit

protected void doExit()
Terminates the application by calling wakeUp() and notifyDestroyed(). Called when the Exit soft button is hit. Also called by destroyApp(), when the system requests to terminate. wakeUp() is called to unblock the main-thread if it is in a waiting state.
Override to get the callback and run your cleanup code. Your callback method is then responsible to unblock a waiting main-thread and call notifyDestroyed().

If the main-thread is blocked in waitOk(), you may call super.doExit() to terminate the main-thread.


doPause

protected void doPause()
Empty. Override to get a callback from the Midlet's pause event.


doOk

protected void doOk()
Empty. Override to get a callback, when the OK soft button is hit. Call the display's addOkButton() to show the button. As usual, keep in mind that the callback method must return quickly, particularly do not create other displays within this callback. Because showMessage() and the readXXX() methods create a Form instance, do not invoke them within doOk().


waitOk

protected static void waitOk(boolean addOkButton)
Waits until a OK soft button is hit. If addOkButton = true and the current display is one of MForm, MTextBox, MPanel, MList, MConsole, Playground, the OK soft button is automatically shown and removed after the OK button is hit.
If the Exit soft button is hit, a RuntimeException is thrown that terminates main() unless you override doExit(). In this case you should call super.doExit() to terminate the application.


waitOk

protected static void waitOk()
Waits until the OK soft button is hit. If the current display is one of MForm, MTextBox, MPanel, MList, MConsole, Playground, the OK soft button is automatically shown and removed after the OK button is hit.
If the Exit soft button is hit, a RuntimeException is thrown that terminates main() unless you override doExit(). In this case you should call super.doExit() to terminate the application.


readInt

protected static int readInt(java.lang.String prompt,
                             int init)
Shows a simple form with an input field with the given prompt message and given initial value. Only non empty integer values are accepted. Block until the OK button is pressed and returns to the previous display. If the Exit soft button is hit, a RuntimeException is thrown that terminates main().


readInt

protected static int readInt(java.lang.String prompt)
Shows a simple form with an input field with the given prompt message and no initial value. Only non empty integer values are accepted. Block until the OK button is pressed and returns to the previous display. If the Exit soft button is hit, a RuntimeException is thrown that terminates main().


readLong

protected static long readLong(java.lang.String prompt,
                               long init)
Shows a simple form with an input field with the given prompt message and given initial value. Only non empty integer values are accepted. Blocks until the OK button is pressed and returns to the previous display. If the Exit soft button is hit, a RuntimeException is thrown that terminates main().


readLong

protected static long readLong(java.lang.String prompt)
Shows a simple form with an input field with the given prompt message and no initial value. Only non empty integer values are accepted. Blocks until the OK button is pressed and returns to the previous display. If the Exit soft button is hit, a RuntimeException is thrown that terminates main().


readDouble

protected static double readDouble(java.lang.String prompt,
                                   double init)
Shows a simple form with an input field with the given prompt message, and given initial value. Only non empty double values are accepted. Blocks until the OK button is pressed and returns to the previous display. If the Exit soft button is hit, a RuntimeException is thrown that terminates main().


readDouble

protected static double readDouble(java.lang.String prompt)
Shows a simple form with an input field with the given prompt message and no initial value. Only non empty double values are accepted. Blocks until the OK button is pressed and returns to the previous display. If the Exit soft button is hit, a RuntimeException is thrown that terminates main().


readString

protected static java.lang.String readString(java.lang.String prompt,
                                             java.lang.String init)
Shows a simple form with an input field with the given prompt message, and given initial value. Any character sequence is accepted. Blocks until the OK button is pressed and returns to the previous display. If the Exit soft button is hit, a RuntimeException is thrown that terminates main().


readString

protected static java.lang.String readString(java.lang.String prompt)
Shows a simple form with an input field with the given prompt message and no initial value. Any character sequences is accepted. Blocks until the OK button is pressed and returns to the previous display. If the Exit soft button is hit, a RuntimeException is thrown that terminates main().


showMessage

public static void showMessage(java.lang.String msg,
                               boolean restore)
Shows a simple form with an output field that contains the given message. Blocks until the OK button is pressed and return to the previous display, if restore = true. If the Exit soft button is hit, a RuntimeException is thrown that terminates main().


showMessage

public static void showMessage(java.lang.String msg)
Shows a simple form with an output field that contains the given message. Blocks until the OK button is pressed and return to the previous display. If the Exit soft button is hit, a RuntimeException is thrown that terminates main().


showTimedMessage

protected void showTimedMessage(java.lang.String msg,
                                int duration)
Shows a simple form during the given duration (in ms) with an output field that contains the given message. Returns immediately, but callback-method messageTimeout() will be triggerd when duration elapses. By overriding messageTimeout() you get your own notification. The callback is canceled by calling closeTimedMessage().
If duration <= 0, no callback is triggered.


messageTimeout

protected void messageTimeout()
Will be called when the timeout of the timed message expires. Empty, should be overridden to get the notification.


closeTimedMessage

protected void closeTimedMessage()
Closes a timed message box before timeout expires. messageTimeout() will not be called.


readTextResource

public static java.lang.String readTextResource(java.lang.String fileUrl)
Reads and returns text from a textfile with given URL. Forward slashes must be used as directory separators. Return null, if textfile isn't found.


getImage

public static javax.microedition.lcdui.Image getImage(java.lang.String imageUrl)
Loads image from given resource and returns it's Image reference. Forward slashes must be used as directory separators. Returns null, if loading fails.


getResource

public static byte[] getResource(java.lang.String resourceUrl)
Loads resource into byte array. Forward slashes must be used as directory separators. Returns null, if loading fails.


getImageHttp

public javax.microedition.lcdui.Image getImageHttp(java.lang.String imageUri,
                                                   int timeout)
Loads image from given HTTP uri and returns it's Image reference. Blocks until image is loaded or time expires the given timeout (in ms). Returns the loaded image or null, if loading fails.


internalNotifyHttpResponse

protected void internalNotifyHttpResponse(byte[] data,
                                          int code)

getSprite

public static javax.microedition.lcdui.game.Sprite getSprite(java.lang.String imageUrl)
Loads image from given resource and returns it's Sprite reference. Returns null, if loading fails.


getSprite

public static javax.microedition.lcdui.game.Sprite getSprite(java.lang.String imageUrl,
                                                             int frameWidth,
                                                             int frameHeight)
Loads image from given resource with given frameWidth, frameHeight and returns it's Sprite reference. Returns null, if loading fails.


sendSMS

protected static int sendSMS(java.lang.String phonenumber,
                             int portnumber,
                             java.lang.String text)
Sends a SMS with given text to given phone and SMS port number. Blocks until the message is sent. If portnumber <= 0, no port number is used. Return values:
0: successful
1: text too long 2: unable to send to the given phone number


sendSMS

protected static int sendSMS(java.lang.String phonenumber,
                             java.lang.String text)
Sends a SMS with given text to given phone number (and no SMS port number). Blocks until the message is sent. Return values:
0: successful
1: text too long 2: unable to send to the given phone number


notifyIncomingSMS

public void notifyIncomingSMS(javax.wireless.messaging.TextMessage msg)
Empty callback method triggered by the SMSReader thread when a SMS is received. Override and use msg.getAddress(): String that contains the sender's identification msg.getTimestamp(): java.util.Date that contains the time of arrival msg.getPayloadText(): String that contains the message Keep in mind that callback method must return quickly. Avoid calls to blocking method.

See Also:
Gidlet.SMSReader

sendMMS

protected static void sendMMS(java.lang.String phonenumber,
                              java.lang.String appId,
                              java.lang.String subject,
                              javax.wireless.messaging.MessagePart[] parts,
                              java.lang.String startContentId)
Sends a MMS to given phone number with given application identifier, subject, message parts and startContentId. If appId = null, no application identifier is used and the MMS is sent to the default MMS application (and not to a MIDlet). The startContendId must be one of the ids of the MessageParts. It helps the receiver to select the part the is responsible for presentation. For more information consult the WMA documentation. Spawns a thread for doing the job and returns immediately. When the job is done, notifyOutgoingMMS() is triggered.

See Also:
notifyOutgoingMMS(int)

sendMMS

protected static void sendMMS(java.lang.String phonenumber,
                              java.lang.String appId,
                              java.lang.String subject,
                              javax.wireless.messaging.MessagePart[] parts)
Sends a MMS to given phone number with given application identifier, subject, and message parts. If appId = null, no application identifier is used and the MMS is sent to the default MMS application (and not to a MIDlet). No startContentId is used. For more information consult the WMA documentation. Spawns a thread for doing the job and returns immediately. When the job is done, notifyOutgoingMMS() is triggered.

See Also:
notifyOutgoingMMS(int)

sendMMSMail

protected static void sendMMSMail(java.lang.String recipient,
                                  java.lang.String subject,
                                  java.lang.String message)
Sends an e-mail via MMS with given recipient's e-mail address, subject and message. The MMS MessagePart's encoding scheme is "ISO-8859-1". Returns immediately, but notifyOutgoingMMS() is triggered when job is done.

See Also:
notifyOutgoingMMS(int)

notifyOutgoingMMS

public void notifyOutgoingMMS(int status)
Empty callback method triggered by the sendMMS() and sendMMSMail() thread when it terminates. Keep in mind that callback method must return quickly. Avoid calls to blocking method.
status values:
0: success
1: error

See Also:
sendMMS(java.lang.String, java.lang.String, java.lang.String, javax.wireless.messaging.MessagePart[], java.lang.String), sendMMSMail(java.lang.String, java.lang.String, java.lang.String)

notifyIncomingMMS

public void notifyIncomingMMS(javax.wireless.messaging.MultipartMessage mpm)
Empty callback method triggered by the MMSReader thread when a MMS is received. Override and use mpm.getMessagePart(String contentID).getContent() to retrieve the data from message parts. For more information consult the WMA documentation. Keep in mind that callback method must return quickly. Avoid calls to blocking method.

See Also:
Gidlet.MMSReader

notifyHttpResponse

public void notifyHttpResponse(byte[] response,
                               int httpCode)
Empty callback method triggered by HttpReader when the transfer due to the HTTP GET command issued by the HttpGetter constructor terminates or when an error occured. Mainly used for transfering binary files (e.g. gif-images). Override and use response: data returned from server in reponse to the HTTP GET command httpCode: HTTP status returned from server or -1 if the request fails (in the latter case, response contains the error description)
Response contains the binary data. Conversion to a string may be performed with new String(data) Keep in mind that callback method must return quickly. Avoid calls to blocking methods.

See Also:
Gidlet.HttpGetter

notifyHttpResponse

public void notifyHttpResponse(java.lang.String response,
                               int httpCode)
Empty callback method triggered by HttpReader when the transfer due to the HTTP GET command issued by the HttpGetter constructor terminates or when an error occured. Override and use response: data returned from server in reponse to the HTTP GET command httpCode: HTTP status returned from server or -1 if the request fails (in the latter case, response contains the error description)
Response contains the text content of the Web page. Keep in mind that callback method must return quickly. Avoid calls to blocking methods.

See Also:
Gidlet.HttpGetter

beep

public static void beep(int type)
Plays a system sound of given type.
0: INFO 1: CONFIRMATION 2: WARNING 3: ALARM 4: ERROR The sound is only emitted if a display (Form, MPanel, etc.) is shown.


getVersion

public static java.lang.String getVersion()
Returns version information of Gidlet framework.


getGidlet

public static Gidlet getGidlet()
Returns a reference to the current gidlet instance.


startTimer

public static void startTimer()
Starts a timer or restart it by setting its time to zero.


getTime

public static long getTime()
Gets timer's time (in ms).


delay

public static void delay(int time)
Delays execution for the given amount of time (in ms). If time is less or equal zero, return immediately.


putSleep

public static boolean putSleep(int timeout)
Puts the current thread in a wait state until wakeUp() is called or timeout (in ms) expires. If timeout <= 0 the method blocks infinitely until wakeUp() is called. Only one thread may be in the wait state.
Return values:
true: wakeUp was called before timeout expired ("no timeout occured")
false: timeout expired before wakeUp was called ("timeout occured")


putSleep

public static boolean putSleep()
Same as putSleep(int timeout) with timeout = 0 (timeout disalbed).


wakeUp

public static void wakeUp()
Wakes up the waiting thread.


isSleeping

public static boolean isSleeping()
Returns true, if putSleep() was called and still waiting for wakeUp() or timeout.

See Also:
putSleep(int), wakeUp()

notifyPlayerUpdate

public void notifyPlayerUpdate(java.lang.String event,
                               java.lang.Object eventData)
Empty callback method triggered by the PlayerListener when the state of the Player is updated. See MMAPI documentation of class javax.microedition.media.PlayerListener for information about event and eventData.

See Also:
PlayerListener

isEmulator

public static boolean isEmulator()
Returns true, if the application runs in the emulator, otherwise false. This methods checks if the system property with key "microedition.platform" ends with "wtk". This may fail on some platforms.


isExiting

public static boolean isExiting()
Returns true, if the Exit soft button is hit in a readXXX(), showMessage() or showTimeMessage() method.


setDebug

public static void setDebug(boolean debug)
Turns on/off debug information on System.out (default: off).
The message is displayed on System.out, but may be redirected by overriding showDebug().

See Also:
showDebug(java.lang.String)

getDebug

public static boolean getDebug()
Returns true if debug information is turned on.


split

public static java.lang.String[] split(java.lang.String s,
                                       java.lang.String separator)
Splits given string with given separator string into multiple strings. Returns splitted string array (without separator).
Array has length 0, if input string is null or empty.
If the given string terminates with the separator, the last array element is an empty string.


readFile

public java.lang.String readFile(java.lang.String fileUrl)
Reads content of a text file from a given url. Runs in a separate thread to improve performance, but waits for the thread to terminate. All resources are released when finishing.

Returns:
content as string, empty if file has zero length, null if operation fails

showDebug

protected void showDebug(java.lang.String msg)
Displays given debug message on System.out, when debugging is enabled by setDebug(true).
May be overridden to redirect the message.

See Also:
setDebug(boolean)