public final class Display extends Object
Form
) on the "display". Before any Form is shown the Developer must
invoke Display.init(Object m) in order to register the current MIDlet.
This class handles the main thread for the toolkit referenced here on as the EDT (Event Dispatch Thread) similar to the Swing EDT. This thread encapsulates the platform specific event delivery and painting semantics and enables threading features such as animations etc...
The EDT should not be blocked since paint operations and events would also be blocked
in much the same way as they would be in other platforms. In order to serialize calls back
into the EDT use the methods callSerially(java.lang.Runnable)
& callSeriallyAndWait(java.lang.Runnable)
.
Notice that all Codename One calls occur on the EDT (events, painting, animations etc...), Codename One
should normally be manipulated on the EDT as well (hence the callSerially(java.lang.Runnable)
&
callSeriallyAndWait(java.lang.Runnable)
methods). Theoretically it should be possible to manipulate
some Codename One features from other threads but this can't be guaranteed to work for all use cases.
Modifier and Type | Field and Description |
---|---|
static int |
COMMAND_BEHAVIOR_BUTTON_BAR
Indicates that commands should be added to an always visible bar at the
bottom of the form.
|
static int |
COMMAND_BEHAVIOR_BUTTON_BAR_TITLE_BACK
Identical to the bar behavior, places the back command within the title bar
of the form/dialg
|
static int |
COMMAND_BEHAVIOR_BUTTON_BAR_TITLE_RIGHT
Places all commands on the right side of the title bar with a uniform size
grid layout
|
static int |
COMMAND_BEHAVIOR_DEFAULT
Indicates that the Codename One implementation should decide internally the command
behavior most appropriate for this platform.
|
static int |
COMMAND_BEHAVIOR_ICS
Commands are placed in the same was as they are in the ice cream sandwich Android
OS update where the back button has a theme icon the application icon appears next
to the
|
static int |
COMMAND_BEHAVIOR_NATIVE
Indicates that commands should try to add themselves to the native menus
|
static int |
COMMAND_BEHAVIOR_SIDE_NAVIGATION
Commands are placed in a side menu similar to Facebook/Google+ apps
|
static int |
COMMAND_BEHAVIOR_SOFTKEY
Indicates the classic Codename One command behavior where the commands are placed in
a list within a dialog.
|
static int |
COMMAND_BEHAVIOR_TOUCH_MENU
Indicates the touch menu dialog rendered by Codename One where commands are placed
into a scrollable dialog
|
static int |
DENSITY_2HD
Double the HD level density
|
static int |
DENSITY_4K
4K level density
|
static int |
DENSITY_560
Intermediate density for screens that sit somewhere between HD to 2HD
|
static int |
DENSITY_HD
HD Up To 1920x1080
|
static int |
DENSITY_HIGH
Hi Density Up To 480x854
|
static int |
DENSITY_LOW
Low Density Up To 240x320
|
static int |
DENSITY_MEDIUM
Medium Density Up To 360x480
|
static int |
DENSITY_VERY_HIGH
Very Hi Density Up To 1440x720
|
static int |
DENSITY_VERY_LOW
Very Low Density 176x220 And Smaller
|
static int |
GALLERY_ALL
Used by openGallery
|
static int |
GALLERY_IMAGE
Used by openGallery
|
static int |
GALLERY_VIDEO
Used by openGallery
|
static int |
GAME_DOWN
Game action for down key
|
static int |
GAME_FIRE
Game action for fire
|
static int |
GAME_LEFT
Game action for left key
|
static int |
GAME_RIGHT
Game action for right key
|
static int |
GAME_UP
Game action for UP key
|
static int |
KEY_POUND
An attribute that encapsulates '#' int value.
|
static int |
KEYBOARD_TYPE_HALF_QWERTY
Half QWERTY which needs software assistance for completion
|
static int |
KEYBOARD_TYPE_NUMERIC
Numeric keypad keyboard type
|
static int |
KEYBOARD_TYPE_QWERTY
Full QWERTY keypad keyboard type, even if a numeric keyboard also exists
|
static int |
KEYBOARD_TYPE_UNKNOWN
Unknown keyboard type is the default indicating the software should try
to detect the keyboard type if necessary
|
static int |
KEYBOARD_TYPE_VIRTUAL
Touch device without a physical keyboard that should popup a keyboad
|
static int |
MEDIA_KEY_FAST_BACKWARD
Special case game key used for media playback events
|
static int |
MEDIA_KEY_FAST_FORWARD
Special case game key used for media playback events
|
static int |
MEDIA_KEY_PLAY
Special case game key used for media playback events
|
static int |
MEDIA_KEY_PLAY_PAUSE
Special case game key used for media playback events
|
static int |
MEDIA_KEY_PLAY_STOP
Special case game key used for media playback events
|
static int |
MEDIA_KEY_SKIP_BACK
Special case game key used for media playback events
|
static int |
MEDIA_KEY_SKIP_FORWARD
Special case game key used for media playback events
|
static int |
MEDIA_KEY_STOP
Special case game key used for media playback events
|
static int |
PICKER_TYPE_DATE
Date native picker type, it returns a java.util.Date result.
|
static int |
PICKER_TYPE_DATE_AND_TIME
Date and time native picker type, it returns a java.util.Date result.
|
static int |
PICKER_TYPE_STRINGS
Strings native picker type, it returns a String result and accepts a String array.
|
static int |
PICKER_TYPE_TIME
Time native picker type, it returns an integer with minutes since midnight.
|
static int |
SHOW_DURING_EDIT_ALLOW_DISCARD
Allow show to occur during edit and discard all user input at this moment
|
static int |
SHOW_DURING_EDIT_ALLOW_SAVE
Allow show to occur during edit and save all user input at this moment
|
static int |
SHOW_DURING_EDIT_EXCEPTION
If show is called while editing text in the native text box an exception is thrown
|
static int |
SHOW_DURING_EDIT_IGNORE
Ignore all calls to show occurring during edit, they are discarded immediately
|
static int |
SHOW_DURING_EDIT_SET_AS_NEXT
Show will update the current form to which the OK button of the text box
will return
|
static int |
SMS_BOTH
Used by getSMSSupport to indicate that SMS can be sent in either seamless or interactive mode
|
static int |
SMS_INTERACTIVE
Used by getSMSSupport to indicate that SMS triggers the native SMS app which will show a compose UI
|
static int |
SMS_NOT_SUPPORTED
Used by getSMSSupport to indicate that SMS is not supported
|
static int |
SMS_SEAMLESS
Used by getSMSSupport to indicate that SMS is sent in the background without a compose UI
|
static String |
SOUND_TYPE_ALARM
A common sound type that can be used with playBuiltinSound
|
static String |
SOUND_TYPE_BUTTON_PRESS
A common sound type that can be used with playBuiltinSound
|
static String |
SOUND_TYPE_CONFIRMATION
A common sound type that can be used with playBuiltinSound
|
static String |
SOUND_TYPE_ERROR
A common sound type that can be used with playBuiltinSound
|
static String |
SOUND_TYPE_INFO
A common sound type that can be used with playBuiltinSound
|
static String |
SOUND_TYPE_WARNING
A common sound type that can be used with playBuiltinSound
|
Modifier and Type | Method and Description |
---|---|
void |
addEdtErrorHandler(ActionListener e)
An error handler will receive an action event with the source exception from the EDT
once an error handler is installed the default Codename One error dialog will no longer appear
|
boolean |
areMutableImagesFast()
On most platforms it is quite fast to draw on a mutable image and then render that
image, however some platforms have much slower mutable images in comparison to just
drawing on the screen.
|
void |
callSerially(Runnable r)
Causes the runnable to be invoked on the event dispatch thread.
|
void |
callSeriallyAndWait(Runnable r)
Identical to callSerially with the added benefit of waiting for the Runnable method to complete.
|
void |
callSeriallyAndWait(Runnable r,
int timeout)
Identical to callSerially with the added benefit of waiting for the Runnable method to complete.
|
boolean |
canDial()
Returns true if the device has dialing capabilities
|
Boolean |
canExecute(String url)
Returns true if executing this URL should work, returns false if it will not
and null if this is unknown.
|
boolean |
canForceOrientation()
Returns true if the device allows forcing the orientation via code, feature phones do not allow this
although some include a jad property allowing for this feature
|
void |
captureAudio(ActionListener response)
This method tries to invoke the device native hardware to capture audio.
|
void |
capturePhoto(ActionListener response)
This method tries to invoke the device native camera to capture images.
|
void |
captureVideo(ActionListener response)
This method tries to invoke the device native camera to capture video.
|
String |
convertBidiLogicalToVisual(String s)
Converts the given string from logical bidi layout to visual bidi layout so
it can be rendered properly on the screen.
|
int |
convertToPixels(int dipCount,
boolean horizontal)
Converts the dips count to pixels, dips are roughly 1mm in length.
|
void |
copyToClipboard(Object obj)
Performs a clipboard copy operation, if the native clipboard is supported by the implementation it would be used
|
String |
createContact(String firstName,
String familyName,
String officePhone,
String homePhone,
String cellPhone,
String email)
Create a contact to the device contacts book
|
Media |
createMedia(InputStream stream,
String mimeType,
Runnable onCompletion)
Create the sound in the given stream
Notice that an audio is "auto destroyed" on completion and cannot be played
twice!
|
Media |
createMedia(String uri,
boolean isVideo,
Runnable onCompletion)
Creates a sound in the given URI which is partially platform specific.
|
Media |
createMediaRecorder(String path)
Deprecated.
|
Media |
createMediaRecorder(String path,
String mimeType)
Creates a Media recorder Object which will record from the device mic to
a file in the given path.
|
Object |
createSoftWeakRef(Object o)
Creates a soft/weak reference to an object that allows it to be collected
yet caches it.
|
static void |
deinitialize()
Closes down the EDT and Codename One, under normal conditions this method is completely unnecessary
since exiting the application will shut down Codename One.
|
void |
delete(String databaseName)
Deletes database
|
boolean |
deleteContact(String id)
removed a contact from the device contacts book
|
void |
deregisterPush()
Stop receiving push notifications to this client application
|
void |
dial(String phoneNumber)
Opens the device Dialer application with the given phone number
|
void |
dismissNotification(Object o)
Removes the notification previously posted with the notify status bar method
|
void |
editString(Component cmp,
int maxSize,
int constraint,
String text)
Encapsulates the editing code which is specific to the platform, some platforms
would allow "in place editing" MIDP does not.
|
void |
editString(Component cmp,
int maxSize,
int constraint,
String text,
int initiatingKeycode)
Encapsulates the editing code which is specific to the platform, some platforms
would allow "in place editing" MIDP does not.
|
void |
execute(String url)
Executes the given URL on the native platform
|
void |
execute(String url,
ActionListener response)
Executes the given URL on the native platform, this method is useful if
the platform has the ability to send an event to the app when the execution
has ended, currently this works only for Android platform to invoke other
intents.
|
boolean |
exists(String databaseName)
Indicates weather a database exists
|
void |
exitApplication()
Exits the application...
|
Object |
extractHardRef(Object o)
Extracts the hard reference from the soft/weak reference given
|
void |
flashBacklight(int duration)
Flash the backlight of the device for the given length of time
|
String[] |
getAllContacts(boolean withNumbers)
Gets all contacts from the address book of the device
|
Contact[] |
getAllContacts(boolean withNumbers,
boolean includesFullName,
boolean includesPicture,
boolean includesNumbers,
boolean includesEmail,
boolean includeAddress)
Notice: this method might be very slow and should be invoked on a separate thread!
It might have platform specific optimizations over getAllContacts followed by looping
over individual contacts but that isn't guaranteed.
|
String[] |
getAvailableRecordingMimeTypes()
Gets the available recording MimeTypes
|
int |
getCharLocation(String source,
int index)
Returns the index of the given char within the source string, the actual
index isn't necessarily the same when bidi is involved
See this
for more on visual vs.
|
CodeScanner |
getCodeScanner()
Returns the native implementation of the code scanner or null
|
int |
getCommandBehavior()
Indicates the way commands should be added to a form as one of the ocmmand constants defined
in this class
|
Contact |
getContactById(String id)
Get a Contact according to it's contact id.
|
Contact |
getContactById(String id,
boolean includesFullName,
boolean includesPicture,
boolean includesNumbers,
boolean includesEmail,
boolean includeAddress)
This method returns a Contact by the contact id and fills it's data
according to the given flags
|
CrashReport |
getCrashReporter()
The crash reporter gets invoked when an uncaught exception is intercepted
|
Form |
getCurrent()
Return the form currently displayed on the screen or null if no form is
currently displayed.
|
String |
getDatabasePath(String databaseName)
Returns the file path of the Database if exists and if supported on
the platform.
|
VirtualKeyboardInterface |
getDefaultVirtualKeyboard()
Get the default virtual keyboard or null if the VirtualKeyboard is disabled
|
int |
getDeviceDensity()
Returns one of the density variables appropriate for this device, notice that
density doesn't always correspond to resolution and an implementation might
decide to change the density based on DPI constraints.
|
int |
getDisplayHeight()
Return the height of the display
|
int |
getDisplayWidth()
Return the width of the display
|
float |
getDragSpeed(boolean yAxis)
This method returns the dragging speed based on the latest dragged
events
|
int |
getDragStartPercentage()
This method allows us to manipulate the drag started detection logic.
|
int |
getFrameRate()
Indicates the maximum frames the API will try to draw every second
|
int |
getGameAction(int keyCode)
Returns the game action code matching the given key combination
|
ImageIO |
getImageIO()
Returns the image IO instance that allows scaling image files.
|
Purchase |
getInAppPurchase()
Returns the native OS purchase implementation if applicable, if unavailable this
method will try to fallback to a custom purchase implementation and failing that
will return null
|
Purchase |
getInAppPurchase(boolean d)
Deprecated.
use the version that accepts no arguments, the physical goods purchase is always
manual payment if applicable
|
static Display |
getInstance()
Return the Display instance
|
int |
getKeyboardType()
Returns the type of the input device one of:
KEYBOARD_TYPE_UNKNOWN, KEYBOARD_TYPE_NUMERIC, KEYBOARD_TYPE_QWERTY,
KEYBOARD_TYPE_VIRTUAL, KEYBOARD_TYPE_HALF_QWERTY
|
int |
getKeyCode(int gameAction)
Deprecated.
this method doesn't work properly across device and is mocked up here
mostly for the case of unit testing. Do not use it for anything other than that! Do
not rely on getKeyCode(GAME_*) == keyCodeFromKeyEvent, this will never actually happen!
|
L10NManager |
getLocalizationManager()
Returns the localization manager instance for this platform
|
LocationManager |
getLocationManager()
This method returns the platform Location Control
|
String |
getMediaRecorderingMimeType()
Deprecated.
see getAvailableRecordingMimeTypes() instead
|
String |
getMsisdn()
Returns the MSISDN for devices that expose it
|
Object |
getPasteDataFromClipboard()
Returns the current content of the clipboard
|
String |
getPlatformName()
Returns a 2-3 letter code representing the platform name for the platform override
|
String[] |
getPlatformOverrides()
Returns the suffixes for ovr files that should be used when loading a layered resource file on this platform
|
String |
getProperty(String key,
String defaultValue)
Returns the property from the underlying platform deployment or the default
value if no deployment values are supported.
|
InputStream |
getResourceAsStream(Class cls,
String resource)
This method is essentially equivalent to cls.getResourceAsStream(String)
however some platforms might define unique ways in which to load resources
within the implementation.
|
int |
getShowDuringEditBehavior()
Returns the status of the show during edit flag
|
int |
getSMSSupport()
Indicates the level of SMS support in the platform as one of: SMS_NOT_SUPPORTED (for desktop, tablet etc.),
SMS_SEAMLESS (no UI interaction), SMS_INTERACTIVE (with compose UI), SMS_BOTH.
|
String[] |
getSupportedVirtualKeyboard()
Returns all platform supported virtual keyboards names
|
String |
getUdid()
Returns the UDID for devices that support it
|
boolean |
hasCamera()
Returns true if the device has camera false otherwise.
|
boolean |
hasDragOccured()
This method should be invoked by components that broadcast events on the pointerReleased callback.
|
boolean |
hasNativeTheme()
Indicates if the implemenetation has a native underlying theme
|
void |
hideNotify()
Broadcasts hide notify into Codename One, this method is invoked by the Codename One implementation
to notify Codename One of hideNotify events
|
static void |
init(Object m)
Deprecated.
this method is invoked internally do not invoke it!
|
void |
installBuiltinSound(String soundIdentifier,
InputStream data)
Installs a replacement sound as the builtin sound responsible for the given
sound identifier (this will override the system sound if such a sound exists).
|
void |
installNativeTheme()
Installs the native theme, this is only applicable if hasNativeTheme() returned true.
|
void |
invokeAndBlock(Runnable r)
Invokes runnable and blocks the current thread, if the current thread is the
edt it will still be blocked however a separate thread would be launched
to perform the duties of the EDT while it is blocked.
|
void |
invokeAndBlock(Runnable r,
boolean dropEvents)
Invokes runnable and blocks the current thread, if the current thread is the
edt it will still be blocked however a separate thread would be launched
to perform the duties of the EDT while it is blocked.
|
boolean |
isAllowMinimizing()
Allows a Codename One application to minimize without forcing it to the front whenever
a new dialog is poped up
|
boolean |
isAutoFoldVKBOnFormSwitch()
Normally Codename One folds the VKB when switching forms this field allows us
to block that behavior.
|
boolean |
isBadgingSupported()
Returns true if the underlying OS supports numeric badges on icons.
|
boolean |
isBidiAlgorithm()
Indicates whether Codename One should consider the bidi RTL algorithm
when drawing text or navigating with the text field cursor.
|
boolean |
isBuiltinSoundAvailable(String soundIdentifier)
Indicates whether a user installed or system sound is available
|
boolean |
isBuiltinSoundsEnabled()
Allows muting/unmuting the builtin sounds easily
|
boolean |
isClickTouchScreen()
Indicates whether the device has a double layer screen thus allowing two
stages to touch events: click and hover.
|
boolean |
isContactsPermissionGranted()
Some platforms allow the user to block contacts access on a per application basis (specifically iOS).
|
boolean |
isDesktop()
Returns true if this is a desktop application
|
boolean |
isEdt()
Returns true if we are currently in the event dispatch thread.
|
boolean |
isGetAllContactsFast()
Indicates if the getAllContacts is platform optimized, notice that the method
might still take seconds or more to run so you should still use a separate thread!
|
static boolean |
isInitialized()
This method returns true if the Display is initialized.
|
boolean |
isMinimized()
Indicates whether an application is minimized
|
boolean |
isMultiKeyMode()
When set to true Codename One allows multiple hardware keys to be pressed at once,
this isn't on by default since it can trigger some complexities with UI navigation to/from
native code
|
boolean |
isMultiTouch()
Indicates whether the device supports multi-touch events, this is only
relevant when touch events are supported
|
boolean |
isNativeCommands()
Deprecated.
use getCommandBehavior() == Display.COMMAND_BEHAVIOR_NATIVE
|
boolean |
isNativeInputSupported()
Indicates whether the device supports native in place editing in which case
lightweight input logic shouldn't be used for input.
|
boolean |
isNativePickerTypeSupported(int pickerType)
Indicates whether the native picker dialog is supported for the given type
which can include one of PICKER_TYPE_DATE_AND_TIME, PICKER_TYPE_TIME, PICKER_TYPE_DATE
|
boolean |
isNativeShareSupported()
Indicates if the underlying platform supports sharing capabilities
|
boolean |
isNativeTitle()
Indicates if the title of the Form is native title(in android ICS devices
if the command behavior is native the ActionBar is used to display the title
and the menu)
|
boolean |
isNativeVideoPlayerControlsIncluded()
Indicates if the native video player includes its own play/pause etc.
|
boolean |
isNotificationSupported()
Indicates whether the notify status bar method will present a notification to the user
|
boolean |
isOpenNativeNavigationAppSupported()
Returns true if the underlying OS supports opening the native navigation
application
|
boolean |
isPortrait()
Returns true if the device is currently in portrait mode
|
boolean |
isPureTouch()
A pure touch device has no focus showing when the user is using the touch
interface.
|
boolean |
isRTL(char c)
Returns true if the given character is an RTL character
|
boolean |
isScreenSaverDisableSupported()
Checks if the device supports disabling the screen display from dimming, allowing
the developer to keep the screen display on.
|
boolean |
isTablet()
Indicates whether the device is a tablet, notice that this is often a guess
|
boolean |
isThirdSoftButton()
Indicates whether the 3rd softbutton should be supported on this device
|
boolean |
isTouchScreenDevice()
Indicates if this is a touch screen device that will return pen events,
defaults to true if the device has pen events but can be overriden by
the developer.
|
boolean |
isVirtualKeyboardShowing()
Indicates if the virtual keyboard is currently showing or not
|
void |
keyPressed(int keyCode)
Pushes a key press event with the given keycode into Codename One
|
void |
keyReleased(int keyCode)
Pushes a key release event with the given keycode into Codename One
|
void |
lockOrientation(boolean portrait)
On devices that return true for canForceOrientation() this method can lock the device orientation
either to portrait or landscape mode
|
boolean |
minimizeApplication()
Minimizes the current application if minimization is supported by the platform (may fail).
|
void |
notifyStatusBar(String tickerText,
String contentTitle,
String contentBody,
boolean vibrate,
boolean flashLights)
Deprecated.
there is a new version of this method with a slightly improved
signature
|
Object |
notifyStatusBar(String tickerText,
String contentTitle,
String contentBody,
boolean vibrate,
boolean flashLights,
Hashtable args)
Place a notification on the device status bar (if device has this
functionality).
|
int |
numAlphaLevels()
Deprecated.
this method isn't implemented in most modern devices
|
int |
numColors()
Deprecated.
this method isn't implemented in most modern devices
|
void |
onEditingComplete(Component c,
String text)
Called by the underlying implementation to indicate that editing in the native
system has completed and changes should propagate into Codename One
|
void |
openGallery(ActionListener response,
int type)
Opens the device gallery
The method returns immediately and the response will be sent asynchronously
to the given ActionListener Object
use this in the actionPerformed to retrieve the file path
String path = (String) evt.getSource();
|
void |
openImageGallery(ActionListener response)
Deprecated.
see openGallery instead
|
void |
openNativeNavigationApp(double latitude,
double longitude)
Opens the native navigation app in the given coordinate.
|
Database |
openOrCreate(String databaseName)
Opens a database or create one if not exists
|
void |
playBuiltinSound(String soundIdentifier)
Plays a builtin device sound matching the given identifier, implementations
and themes can offer additional identifiers to the ones that are already built
in.
|
void |
pointerDragged(int[] x,
int[] y)
Pushes a pointer drag event with the given coordinates into Codename One
|
void |
pointerHover(int[] x,
int[] y)
Pushes a pointer hover event with the given coordinates into Codename One
|
void |
pointerHoverPressed(int[] x,
int[] y)
Pushes a pointer hover release event with the given coordinates into Codename One
|
void |
pointerHoverReleased(int[] x,
int[] y)
Pushes a pointer hover release event with the given coordinates into Codename One
|
void |
pointerPressed(int[] x,
int[] y)
Pushes a pointer press event with the given coordinates into Codename One
|
void |
pointerReleased(int[] x,
int[] y)
Pushes a pointer release event with the given coordinates into Codename One
|
void |
refreshNativeTitle()
if the title is native(e.g the android action bar), notify the native title
that is needs to be refreshed
|
void |
registerPush(Hashtable metaData,
boolean noFallback)
Register to receive push notification, invoke this method once (ever) to receive push
notifications.
|
void |
registerPush(String id,
boolean noFallback)
Deprecated.
use the version that doesn't take an id argument this argument is effectively ignored!
|
void |
registerVirtualKeyboard(VirtualKeyboardInterface vkb)
Register a virtual keyboard
|
void |
removeEdtErrorHandler(ActionListener e)
An error handler will receive an action event with the source exception from the EDT
once an error handler is installed the default Codename One error dialog will no longer appear
|
void |
restoreMinimizedApplication()
Restore the minimized application if minimization is supported by the platform
|
void |
scheduleBackgroundTask(Runnable r)
Allows executing a background task in a separate low priority thread.
|
void |
sendMessage(String[] recipients,
String subject,
Message msg)
Send an email using the platform mail client
|
void |
sendSMS(String phoneNumber,
String message)
Sends a SMS message to the given phone number
|
void |
sendSMS(String phoneNumber,
String message,
boolean interactive)
Sends a SMS message to the given phone number
|
void |
setAllowMinimizing(boolean allowMinimizing)
Allows a Codename One application to minimize without forcing it to the front whenever
a new dialog is poped up
|
void |
setAutoFoldVKBOnFormSwitch(boolean autoFoldVKBOnFormSwitch)
Normally Codename One folds the VKB when switching forms this field allows us
to block that behavior.
|
void |
setBadgeNumber(int number)
Sets the number that appears on the application icon in iOS
|
void |
setBidiAlgorithm(boolean activate)
Indicates whether Codename One should consider the bidi RTL algorithm
when drawing text or navigating with the text field cursor.
|
void |
setBuiltinSoundsEnabled(boolean enabled)
Allows muting/unmuting the builtin sounds easily
|
void |
setCommandBehavior(int commandBehavior)
Indicates the way commands should be added to a form as one of the ocmmand constants defined
in this class
|
void |
setCrashReporter(CrashReport crashReporter)
The crash reporter gets invoked when an uncaught exception is intercepted
|
void |
setDefaultVirtualKeyboard(VirtualKeyboardInterface vkb)
Sets the default virtual keyboard to be used by the platform
|
void |
setDragStartPercentage(int dragStartPercentage)
This method allows us to manipulate the drag started detection logic.
|
void |
setFramerate(int rate)
Indicates the maximum frames the API will try to draw every second
by default this is set to 10.
|
void |
setMultiKeyMode(boolean multiKeyMode)
When set to true Codename One allows multiple hardware keys to be pressed at once,
this isn't on by default since it can trigger some complexities with UI navigation to/from
native code
|
void |
setNativeCommands(boolean nativeCommands)
Deprecated.
use setCommandBehavior(Display.COMMAND_BEHAVIOR_NATIVE)
|
void |
setNoSleep(boolean noSleep)
Calling this method with noSleep=true will cause the edt to run without sleeping.
|
void |
setPollingFrequency(int freq)
Sets the frequency for polling the server in case of polling based push notification
|
void |
setProperty(String key,
String value)
Sets a local property to the application, this method has no effect on the
implementation code and only allows the user to override the logic of getProperty
for internal application purposes.
|
void |
setPureTouch(boolean pureTouch)
A pure touch device has no focus showing when the user is using the touch
interface.
|
void |
setScreenSaverEnabled(boolean e)
If isScreenSaverDisableSupported() returns true calling this method will
lock the screen display on
|
void |
setShowDuringEditBehavior(int showDuringEdit)
Invoking the show() method of a form/dialog while the user is editing
text in the native text box can have several behaviors: SHOW_DURING_EDIT_IGNORE,
SHOW_DURING_EDIT_EXCEPTION, SHOW_DURING_EDIT_ALLOW_DISCARD,
SHOW_DURING_EDIT_ALLOW_SAVE, SHOW_DURING_EDIT_SET_AS_NEXT
|
void |
setShowVirtualKeyboard(boolean show)
Displays the virtual keyboard on devices that support manually poping up
the vitual keyboard
|
void |
setThirdSoftButton(boolean thirdSoftButton)
Indicates whether the 3rd softbutton should be supported on this device
|
void |
setTouchScreenDevice(boolean touchScreen)
Indicates if this is a touch screen device that will return pen events,
defaults to true if the device has pen events but can be overriden by
the developer.
|
void |
setTransitionYield(int transitionD)
Indicates whether a delay should exist between calls to flush graphics during
transition.
|
void |
share(String toShare)
Deprecated.
use the method share that accepts an image and mime type
|
void |
share(String text,
String image,
String mimeType)
Share the required information using the platform sharing services.
|
void |
share(String text,
String image,
String mimeType,
Rectangle sourceRect)
Share the required information using the platform sharing services.
|
boolean |
shouldRenderSelection()
This is an internal state flag relevant only for pureTouch mode (otherwise it
will always be true).
|
boolean |
shouldRenderSelection(Component c)
This is an internal state flag relevant only for pureTouch mode (otherwise it
will always be true).
|
Object |
showNativePicker(int type,
Component source,
Object currentValue,
Object data)
Shows a native modal dialog allowing us to perform the picking for the given type
which can include one of PICKER_TYPE_DATE_AND_TIME, PICKER_TYPE_TIME, PICKER_TYPE_DATE
|
void |
showNativeScreen(Object nativeFullScreenPeer)
Shows a native Form/Canvas or some other heavyweight native screen
|
void |
showNotify()
Broadcasts show notify into Codename One, this method is invoked by the Codename One implementation
to notify Codename One of showNotify events
|
void |
sizeChanged(int w,
int h)
Notifies Codename One of display size changes, this method is invoked by the implementation
class and is for internal use
|
Thread |
startThread(Runnable r,
String name)
Start a Codename One thread that supports crash protection and similar Codename One features.
|
void |
stopEditing(Component cmp)
Allows us to stop editString on the given text component
|
void |
unlockOrientation()
This is the reverse method for lock orientation allowing orientation lock to be disabled
|
void |
vibrate(int duration)
Vibrates the device for the given length of time
|
public static final String SOUND_TYPE_ALARM
public static final String SOUND_TYPE_CONFIRMATION
public static final String SOUND_TYPE_ERROR
public static final String SOUND_TYPE_INFO
public static final String SOUND_TYPE_WARNING
public static final String SOUND_TYPE_BUTTON_PRESS
public static final int KEYBOARD_TYPE_UNKNOWN
public static final int KEYBOARD_TYPE_NUMERIC
public static final int KEYBOARD_TYPE_QWERTY
public static final int KEYBOARD_TYPE_VIRTUAL
public static final int KEYBOARD_TYPE_HALF_QWERTY
public static final int SMS_NOT_SUPPORTED
public static final int SMS_SEAMLESS
public static final int SMS_INTERACTIVE
public static final int SMS_BOTH
public static final int GALLERY_IMAGE
public static final int GALLERY_VIDEO
public static final int GALLERY_ALL
public static final int DENSITY_VERY_LOW
public static final int DENSITY_LOW
public static final int DENSITY_MEDIUM
public static final int DENSITY_HIGH
public static final int DENSITY_VERY_HIGH
public static final int DENSITY_HD
public static final int DENSITY_560
public static final int DENSITY_2HD
public static final int DENSITY_4K
public static final int PICKER_TYPE_DATE
public static final int PICKER_TYPE_TIME
public static final int PICKER_TYPE_DATE_AND_TIME
public static final int PICKER_TYPE_STRINGS
public static final int GAME_FIRE
public static final int GAME_LEFT
public static final int GAME_RIGHT
public static final int GAME_UP
public static final int GAME_DOWN
public static final int MEDIA_KEY_SKIP_FORWARD
public static final int MEDIA_KEY_SKIP_BACK
public static final int MEDIA_KEY_PLAY
public static final int MEDIA_KEY_STOP
public static final int MEDIA_KEY_PLAY_STOP
public static final int MEDIA_KEY_PLAY_PAUSE
public static final int MEDIA_KEY_FAST_FORWARD
public static final int MEDIA_KEY_FAST_BACKWARD
public static final int KEY_POUND
public static final int SHOW_DURING_EDIT_IGNORE
public static final int SHOW_DURING_EDIT_EXCEPTION
public static final int SHOW_DURING_EDIT_ALLOW_DISCARD
public static final int SHOW_DURING_EDIT_ALLOW_SAVE
public static final int SHOW_DURING_EDIT_SET_AS_NEXT
public static final int COMMAND_BEHAVIOR_DEFAULT
public static final int COMMAND_BEHAVIOR_SOFTKEY
public static final int COMMAND_BEHAVIOR_TOUCH_MENU
public static final int COMMAND_BEHAVIOR_BUTTON_BAR
public static final int COMMAND_BEHAVIOR_BUTTON_BAR_TITLE_BACK
public static final int COMMAND_BEHAVIOR_BUTTON_BAR_TITLE_RIGHT
public static final int COMMAND_BEHAVIOR_ICS
public static final int COMMAND_BEHAVIOR_SIDE_NAVIGATION
public static final int COMMAND_BEHAVIOR_NATIVE
public static void init(Object m)
m
- the main running MIDletpublic static void deinitialize()
public static boolean isInitialized()
public static Display getInstance()
public int getDragStartPercentage()
public void setDragStartPercentage(int dragStartPercentage)
dragStartPercentage
- percentage of the screen required to initiate dragpublic void setFramerate(int rate)
rate
- the frame ratepublic void vibrate(int duration)
duration
- length of time to vibratepublic void flashBacklight(int duration)
duration
- length of time to flash the backlightpublic void setShowDuringEditBehavior(int showDuringEdit)
showDuringEdit
- one of the following: SHOW_DURING_EDIT_IGNORE,
SHOW_DURING_EDIT_EXCEPTION, SHOW_DURING_EDIT_ALLOW_DISCARD,
SHOW_DURING_EDIT_ALLOW_SAVE, SHOW_DURING_EDIT_SET_AS_NEXTpublic int getShowDuringEditBehavior()
public int getFrameRate()
public boolean isEdt()
public void callSerially(Runnable r)
r
- runnable (NOT A THREAD!) that will be invoked on the EDT serial to
the paint and key handling eventspublic void scheduleBackgroundTask(Runnable r)
r
- the task to perform in the backgroundpublic void callSeriallyAndWait(Runnable r)
r
- runnable (NOT A THREAD!) that will be invoked on the EDT serial to
the paint and key handling eventsIllegalStateException
- if this method is invoked on the event dispatch thread (e.g. during
paint or event handling).public void callSeriallyAndWait(Runnable r, int timeout)
r
- runnable (NOT A THREAD!) that will be invoked on the EDT serial to
the paint and key handling eventstimeout
- timeout duration, on timeout the method just returnsIllegalStateException
- if this method is invoked on the event dispatch thread (e.g. during
paint or event handling).public void onEditingComplete(Component c, String text)
c
- edited componenttext
- new text for the componentpublic void invokeAndBlock(Runnable r, boolean dropEvents)
r
- runnable (NOT A THREAD!) that will be invoked synchroniously by this methoddropEvents
- indicates if the display should drop all events
while this runnable is runningpublic void invokeAndBlock(Runnable r)
r
- runnable (NOT A THREAD!) that will be invoked synchroniously by this methodpublic boolean isTouchScreenDevice()
public void setTouchScreenDevice(boolean touchScreen)
touchScreen
- false if this is not a touch screen devicepublic void setNoSleep(boolean noSleep)
noSleep
- causes the edt to stop the sleeping periods between 2 cyclespublic void setTransitionYield(int transitionD)
transitionD
- -1 for no delay otherwise delay in millisecondspublic void editString(Component cmp, int maxSize, int constraint, String text)
cmp
- the TextArea
componentmaxSize
- the maximum size from the text areaconstraint
- the constraints of the text areatext
- the string to editpublic void editString(Component cmp, int maxSize, int constraint, String text, int initiatingKeycode)
cmp
- the TextArea
componentmaxSize
- the maximum size from the text areaconstraint
- the constraints of the text areatext
- the string to editinitiatingKeycode
- the keycode used to initiate the edit.public void stopEditing(Component cmp)
cmp
- the text field/text area componentpublic boolean minimizeApplication()
public boolean isMinimized()
public void restoreMinimizedApplication()
public void keyPressed(int keyCode)
keyCode
- keycode of the key eventpublic void keyReleased(int keyCode)
keyCode
- keycode of the key eventpublic void pointerDragged(int[] x, int[] y)
x
- the x position of the pointery
- the y position of the pointerpublic void pointerHover(int[] x, int[] y)
x
- the x position of the pointery
- the y position of the pointerpublic void pointerHoverPressed(int[] x, int[] y)
x
- the x position of the pointery
- the y position of the pointerpublic void pointerHoverReleased(int[] x, int[] y)
x
- the x position of the pointery
- the y position of the pointerpublic void pointerPressed(int[] x, int[] y)
x
- the x position of the pointery
- the y position of the pointerpublic void pointerReleased(int[] x, int[] y)
x
- the x position of the pointery
- the y position of the pointerpublic void sizeChanged(int w, int h)
w
- the width of the drawing surfaceh
- the height of the drawing surfacepublic void hideNotify()
public void showNotify()
public boolean hasDragOccured()
public Form getCurrent()
public int numAlphaLevels()
public int numColors()
public int getDisplayWidth()
public int getDisplayHeight()
public int convertToPixels(int dipCount, boolean horizontal)
dipCount
- the dips that we will convert to pixelshorizontal
- indicates pixels in the horizontal planepublic int getGameAction(int keyCode)
keyCode
- key code received from the eventpublic int getKeyCode(int gameAction)
gameAction
- game action constant from this classpublic boolean isThirdSoftButton()
public void setThirdSoftButton(boolean thirdSoftButton)
thirdSoftButton
- true if a third softbutton should be usedpublic void setShowVirtualKeyboard(boolean show)
show
- toggles the virtual keyboards visibilitypublic boolean isVirtualKeyboardShowing()
public String[] getSupportedVirtualKeyboard()
public void registerVirtualKeyboard(VirtualKeyboardInterface vkb)
vkb
- public void setDefaultVirtualKeyboard(VirtualKeyboardInterface vkb)
vkb
- a VirtualKeyboard to be used or null to disable the
VirtualKeyboardpublic VirtualKeyboardInterface getDefaultVirtualKeyboard()
public int getKeyboardType()
public boolean isNativeInputSupported()
public boolean isMultiTouch()
public boolean isClickTouchScreen()
A click touch screen will also send pointer hover events to the underlying software and will only send the standard pointer events on click.
public float getDragSpeed(boolean yAxis)
yAxis
- indicates what axis speed is requiredpublic boolean isBidiAlgorithm()
public void setBidiAlgorithm(boolean activate)
activate
- set to true to activate the bidi algorithm, false to
disable itpublic String convertBidiLogicalToVisual(String s)
s
- a "logical" string with RTL characterspublic int getCharLocation(String source, int index)
source
- the string in which we are looking for the positionindex
- the "logical" location of the cursorpublic boolean isRTL(char c)
c
- character to testpublic InputStream getResourceAsStream(Class cls, String resource)
cls
- class to load the resource fromresource
- relative/absolute URL based on the Java conventionpublic void addEdtErrorHandler(ActionListener e)
e
- listener receiving the errorspublic void removeEdtErrorHandler(ActionListener e)
e
- listener receiving the errorspublic void setAllowMinimizing(boolean allowMinimizing)
allowMinimizing
- valuepublic boolean isAllowMinimizing()
public boolean shouldRenderSelection()
public boolean shouldRenderSelection(Component c)
c
- the component to test against, this prevents a touch outside of the component that triggers a repaint from painting the component selectionpublic boolean isPureTouch()
public void setPureTouch(boolean pureTouch)
pureTouch
- the value for pureTouchpublic boolean isNativeCommands()
public void setNativeCommands(boolean nativeCommands)
nativeCommands
- the flag to setpublic void exitApplication()
public void showNativeScreen(Object nativeFullScreenPeer)
nativeFullScreenPeer
- the native screen peerpublic boolean isAutoFoldVKBOnFormSwitch()
public void setAutoFoldVKBOnFormSwitch(boolean autoFoldVKBOnFormSwitch)
autoFoldVKBOnFormSwitch
- the autoFoldVKBOnFormSwitch to setpublic int getCommandBehavior()
public void setCommandBehavior(int commandBehavior)
commandBehavior
- the commandBehavior to setpublic String getProperty(String key, String defaultValue)
The implementation should be responsible for the following keys to return reasonable valid values for the application:
key
- the key of the propertydefaultValue
- a default return valuepublic void setProperty(String key, String value)
key
- key the key of the propertyvalue
- the value of the propertypublic Boolean canExecute(String url)
url
- the url that would be executedpublic void execute(String url)
url
- the url to executepublic void execute(String url, ActionListener response)
url
- the url to executeresponse
- a callback from the platform when this execution returned
to the applicationpublic int getDeviceDensity()
public void playBuiltinSound(String soundIdentifier)
soundIdentifier
- the sound identifier which can match one of the
common constants in this class or be a user/implementation defined soundpublic void installBuiltinSound(String soundIdentifier, InputStream data) throws IOException
soundIdentifier
- the sound string passed to playBuiltinSounddata
- an input stream containing platform specific audio file, its usually safe
to assume that wav/mp3 would be supported.IOException
- if the stream throws an exceptionpublic boolean isBuiltinSoundAvailable(String soundIdentifier)
soundIdentifier
- the sound string passed to playBuiltinSoundpublic void setBuiltinSoundsEnabled(boolean enabled)
enabled
- indicates whether the sound is mutedpublic boolean isBuiltinSoundsEnabled()
public Media createMedia(String uri, boolean isVideo, Runnable onCompletion) throws IOException
uri
- the platform specific location for the soundonCompletion
- invoked when the audio file finishes playing, may be nullIOException
- if the URI access failspublic Media createMedia(InputStream stream, String mimeType, Runnable onCompletion) throws IOException
stream
- the stream containing the media datamimeType
- the type of the data in the streamonCompletion
- invoked when the audio file finishes playing, may be nullIOException
- if the URI access failspublic Object createSoftWeakRef(Object o)
o
- object to cachepublic Object extractHardRef(Object o)
o
- the reference returned by createSoftWeakRefpublic boolean hasNativeTheme()
public void installNativeTheme()
public void copyToClipboard(Object obj)
obj
- object to copy, while this can be any arbitrary object it is recommended that only Strings or Codename One
image objects be used to copypublic Object getPasteDataFromClipboard()
public boolean isPortrait()
public boolean canForceOrientation()
public void lockOrientation(boolean portrait)
portrait
- true to lock to portrait mode, false to lock to landscape modepublic void unlockOrientation()
public boolean isTablet()
public boolean isDesktop()
public boolean canDial()
public boolean areMutableImagesFast()
public LocationManager getLocationManager()
public void capturePhoto(ActionListener response)
response
- a callback Object to retrieve the file pathRuntimeException
- if this feature failed or unsupported on the platformpublic void captureAudio(ActionListener response)
response
- a callback Object to retrieve the file pathRuntimeException
- if this feature failed or unsupported on the platformpublic void captureVideo(ActionListener response)
response
- a callback Object to retrieve the file pathRuntimeException
- if this feature failed or unsupported on the platformpublic void openImageGallery(ActionListener response)
response
- a callback Object to retrieve the file pathRuntimeException
- if this feature failed or unsupported on the platformpublic void openGallery(ActionListener response, int type)
response
- a callback Object to retrieve the file pathtype
- one of the following GALLERY_IMAGE, GALLERY_VIDEO, GALLERY_ALLRuntimeException
- if this feature failed or unsupported on the platformpublic String getPlatformName()
public String[] getPlatformOverrides()
public void sendMessage(String[] recipients, String subject, Message msg)
recipients
- array of e-mail addressessubject
- e-mail subjectmsg
- the Message to sendpublic void dial(String phoneNumber)
phoneNumber
- public int getSMSSupport()
public void sendSMS(String phoneNumber, String message) throws IOException
phoneNumber
- to send the smsmessage
- the content of the smsIOException
public void sendSMS(String phoneNumber, String message, boolean interactive) throws IOException
phoneNumber
- to send the smsmessage
- the content of the smsinteractive
- indicates the SMS should show a UI or should not show a UI if applicable see getSMSSupportIOException
public void notifyStatusBar(String tickerText, String contentTitle, String contentBody, boolean vibrate, boolean flashLights)
tickerText
- the ticker text of the NotificationcontentTitle
- the title of the NotificationcontentBody
- the content of the Notificationvibrate
- enable/disable notification alertflashLights
- enable/disable notification flashingpublic boolean isNotificationSupported()
public Object notifyStatusBar(String tickerText, String contentTitle, String contentBody, boolean vibrate, boolean flashLights, Hashtable args)
tickerText
- the ticker text of the NotificationcontentTitle
- the title of the NotificationcontentBody
- the content of the Notificationvibrate
- enable/disable notification alertflashLights
- enable/disable notification flashingargs
- additional arguments to the notificationpublic void dismissNotification(Object o)
o
- the object returned from the notifyStatusBar methodpublic boolean isBadgingSupported()
public void setBadgeNumber(int number)
number
- number to show on the iconpublic boolean isOpenNativeNavigationAppSupported()
public void openNativeNavigationApp(double latitude, double longitude)
latitude
- longitude
- public String[] getAllContacts(boolean withNumbers)
withNumbers
- if true returns only contacts that has a numberpublic Contact[] getAllContacts(boolean withNumbers, boolean includesFullName, boolean includesPicture, boolean includesNumbers, boolean includesEmail, boolean includeAddress)
withNumbers
- if true returns only contacts that has a numberincludesFullName
- if true try to fetch the full name of the Contact(not just display name)includesPicture
- if true try to fetch the Contact Picture if existsincludesNumbers
- if true try to fetch all Contact numbersincludesEmail
- if true try to fetch all Contact EmailsincludeAddress
- if true try to fetch all Contact Addressespublic boolean isGetAllContactsFast()
public Contact getContactById(String id)
id
- unique id of the Contactpublic Contact getContactById(String id, boolean includesFullName, boolean includesPicture, boolean includesNumbers, boolean includesEmail, boolean includeAddress)
id
- of the ContactincludesFullName
- if true try to fetch the full name of the Contact(not just display name)includesPicture
- if true try to fetch the Contact Picture if existsincludesNumbers
- if true try to fetch all Contact numbersincludesEmail
- if true try to fetch all Contact EmailsincludeAddress
- if true try to fetch all Contact Addressespublic boolean isContactsPermissionGranted()
public String createContact(String firstName, String familyName, String officePhone, String homePhone, String cellPhone, String email)
firstName
- the Contact firstNamefamilyName
- the Contact familyNameworkPhone
- the Contact work phone or nullhomePhone
- the Contact home phone or nullmobilePhone
- the Contact mobile phone or nullemail
- the Contact email or nullpublic boolean deleteContact(String id)
id
- the contact id to removepublic boolean isNativeVideoPlayerControlsIncluded()
public boolean isNativeShareSupported()
public void share(String toShare)
toShare
- String to share.public void share(String text, String image, String mimeType)
text
- String to share.image
- file path to the image or nullmime
- type of the image or null if no image to sharepublic void share(String text, String image, String mimeType, Rectangle sourceRect)
text
- String to share.image
- file path to the image or nullmime
- type of the image or null if no image to sharesourceRect
- The source rectangle of the button that originated the share request. This is used on
some platforms to provide a hint as to where the share dialog overlay should pop up. Particularly,
on the iPad with iOS 8 and higher.public L10NManager getLocalizationManager()
public void registerPush(String id, boolean noFallback)
id
- the id for the usernoFallback
- some devices don't support an efficient push API and will resort to polling
to provide push like functionality. If this flag is set to true no polling will occur and
the error PushCallback.REGISTRATION_ERROR_SERVICE_NOT_AVAILABLE will be sent to the push interface.public void registerPush(Hashtable metaData, boolean noFallback)
metaData
- meta data for push, this is relevant on some platforms such as google where
a push id is necessary,noFallback
- some devices don't support an efficient push API and will resort to polling
to provide push like functionality. If this flag is set to true no polling will occur and
the error PushCallback.REGISTRATION_ERROR_SERVICE_NOT_AVAILABLE will be sent to the push interface.public void deregisterPush()
public Media createMediaRecorder(String path) throws IOException
path
- a file path to where to store the recording, if the file does
not exists it will be created.IOException
public Media createMediaRecorder(String path, String mimeType) throws IOException
path
- a file path to where to store the recording, if the file does
not exists it will be created.mimeType
- the output mime type that is supported see
getAvailableRecordingMimeTypes()IOException
public ImageIO getImageIO()
public String getMediaRecorderingMimeType()
public Database openOrCreate(String databaseName) throws IOException
databaseName
- the name of the databaseIOException
- if database cannot be createdpublic void delete(String databaseName) throws IOException
databaseName
- the name of the databaseIOException
- if database cannot be deletedpublic boolean exists(String databaseName)
databaseName
- the name of the databasepublic String getDatabasePath(String databaseName)
public void setPollingFrequency(int freq)
freq
- the frequency in millisecondspublic Thread startThread(Runnable r, String name)
r
- runnable to run, NOTICE the thread MUST be explicitly started!name
- the name for the threadpublic boolean isNativeTitle()
public void refreshNativeTitle()
public CrashReport getCrashReporter()
public void setCrashReporter(CrashReport crashReporter)
crashReporter
- the crashReporter to setpublic String getUdid()
public String getMsisdn()
public Purchase getInAppPurchase()
public Purchase getInAppPurchase(boolean d)
public CodeScanner getCodeScanner()
public String[] getAvailableRecordingMimeTypes()
public boolean isScreenSaverDisableSupported()
public void setScreenSaverEnabled(boolean e)
e
- when set to true the screen saver will work as usual and when set to false the screen
will not turn off automaticallypublic boolean hasCamera()
public boolean isNativePickerTypeSupported(int pickerType)
pickerType
- the picker type constantpublic Object showNativePicker(int type, Component source, Object currentValue, Object data)
type
- the picker type constantsource
- the source component (optional) the native dialog will be placed in relation to this
component if applicablecurrentValue
- the currently selected valuedata
- additional meta data specific to the picker type when applicablepublic boolean isMultiKeyMode()
public void setMultiKeyMode(boolean multiKeyMode)
multiKeyMode
- the multiKeyMode to set