public final class Display extends CN1Constants
Form
) on the "display".
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 |
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 |
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 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
|
DENSITY_2HD, DENSITY_4K, DENSITY_560, DENSITY_HD, DENSITY_HIGH, DENSITY_LOW, DENSITY_MEDIUM, DENSITY_VERY_HIGH, DENSITY_VERY_LOW, GALLERY_ALL, GALLERY_ALL_MULTI, GALLERY_IMAGE, GALLERY_IMAGE_MULTI, GALLERY_VIDEO, GALLERY_VIDEO_MULTI, PICKER_TYPE_CALENDAR, PICKER_TYPE_DATE, PICKER_TYPE_DATE_AND_TIME, PICKER_TYPE_DURATION, PICKER_TYPE_DURATION_HOURS, PICKER_TYPE_DURATION_MINUTES, PICKER_TYPE_STRINGS, PICKER_TYPE_TIME, SMS_BOTH, SMS_INTERACTIVE, SMS_NOT_SUPPORTED, SMS_SEAMLESS
Modifier and Type | Method and Description |
---|---|
void |
addCompletionHandler(Media media,
Runnable onCompletion)
Adds a callback to a Media element that will be called when the media finishes playing.
|
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
|
void |
addMessageListener(ActionListener<MessageEvent> l)
Adds a listener to receive messages from the native platform.
|
void |
addVirtualKeyboardListener(ActionListener l)
Adds a listener for VirtualKeyboard hide/show events.
|
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.
|
void |
callSeriallyOnIdle(Runnable r)
Causes the runnable to be invoked on the event dispatch thread when the event
dispatch thread is idle.
|
void |
cancelLocalNotification(String notificationId)
Cancels a local notification by ID.
|
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
|
boolean |
canInstallOnHomescreen()
Checks to see if you can prompt the user to install the app on their homescreen.
|
void |
captureAudio(ActionListener response)
This method tries to invoke the device native hardware to capture audio.
|
void |
captureAudio(MediaRecorderBuilder recordingOptions,
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.
|
Image |
captureScreen()
Captures a screenshot of the screen.
|
void |
captureVideo(ActionListener response)
This method tries to invoke the device native camera to capture video.
|
void |
captureVideo(VideoCaptureConstraints constraints,
ActionListener response)
Same as
captureVideo(com.codename1.ui.events.ActionListener) , except that it
attempts to impose constraints on the capture. |
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(float dipCount)
Converts the dips count to pixels, dips are roughly 1mm in length.
|
int |
convertToPixels(float value,
byte unitType)
Converts from specified unit to pixels.
|
int |
convertToPixels(float value,
byte unitType,
boolean horizontal)
Converts from specified unit to pixels.
|
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
|
Media |
createBackgroundMedia(String uri)
Creates an audio media that can be played in the background.
|
AsyncResource<Media> |
createBackgroundMediaAsync(String uri)
Creates an audio media that can be played in the background.
|
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.
|
AsyncResource<Media> |
createMediaAsync(InputStream stream,
String mimeType,
Runnable onCompletion) |
AsyncResource<Media> |
createMediaAsync(String uri,
boolean video,
Runnable onCompletion)
Creates media asynchronously.
|
Media |
createMediaRecorder(MediaRecorderBuilder builder)
Deprecated.
use MediaRecorderBuilder#build()
|
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.
|
Thread |
createThread(Runnable r,
String name)
Start a Codename One thread that supports crash protection and similar Codename One features.
|
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 |
dispatchMessage(MessageEvent evt)
Dispatches a message to all of the registered listeners.
|
void |
editString(Component cmp,
int maxSize,
int constraint,
String text)
Fires the native in place text editing logic, normally you wouldn't invoke this API directly and instead
use an API like
TextArea.startEditingAsync() , TextArea.startEditing()
or Form.setEditOnShow(com.codename1.ui.TextArea) . |
void |
editString(Component cmp,
int maxSize,
int constraint,
String text,
int initiatingKeycode)
Fires the native in place text editing logic, normally you wouldn't invoke this API directly and instead
use an API like
TextArea.startEditingAsync() , TextArea.startEditing()
or Form.setEditOnShow(com.codename1.ui.TextArea) . |
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...
|
boolean |
exitFullScreen()
Try to exit full-screen mode if the platform supports it.
|
Object |
extractHardRef(Object o)
Extracts the hard reference from the soft/weak reference given
|
void |
fireVirtualKeyboardEvent(boolean show)
Fires a virtual keyboard show event.
|
void |
flashBacklight(int duration)
Deprecated.
this refers to functionality of devices that are no longer sold, not to the devices "flash"
|
Image |
gaussianBlurImage(Image image,
float radius)
Create a blur image from the given image.
|
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()
Deprecated.
Use the cn1-codescanner cn1lib.
|
int |
getCommandBehavior()
Deprecated.
we recommend migrating to the
Toolbar API. When using the toolbar the command
behavior can't be manipulated |
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.
The sample below demonstrates listing all the contacts within the device with their photos |
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 support for database exists
on the platform.
|
VirtualKeyboardInterface |
getDefaultVirtualKeyboard()
Deprecated.
this method is only used in feature phones and has no modern equivalent
|
String |
getDensityStr()
Returns the device density as a string.
|
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
|
Rectangle |
getDisplaySafeArea(Rectangle rect)
Gets the display safe area as a rectangle.
|
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 |
getInvisibleAreaUnderVKB()
Gets the invisible area under the Virtual Keyboard.
|
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!
|
String |
getLineSeparator() |
String[] |
getLinkedContactIds(Contact c)
Gets IDs of all contacts that are linked to a given contact.
|
L10NManager |
getLocalizationManager()
The localization manager allows adapting values for display in different locales thru parsing and formatting
capabilities (similar to JavaSE's DateFormat/NumberFormat).
|
LocationManager |
getLocationManager()
This method returns the platform Location Manager used for geofencing.
|
int |
getLongPointerPressInterval()
Long pointer press is invoked after the given interval, this allows making long press events shorter/longer
|
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
|
PluginSupport |
getPluginSupport()
Gets reference to plugin support object.
|
int |
getPreferredBackgroundFetchInterval(int seconds)
Gets the preferred time (in seconds) between background fetches.
|
Map<String,String> |
getProjectBuildHints()
Returns the build hints for the simulator, this will only work in the debug environment and it's
designed to allow extensions/API's to verify user settings/build hints exist
|
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.
|
BrowserComponent |
getSharedJavascriptContext()
Gets a reference to an application-wide shared Javascript context that can be used for running
Javascript commands.
|
int |
getShowDuringEditBehavior()
Deprecated.
this method isn't applicable in modern devices
|
int |
getSMSSupport()
Indicates the level of SMS support in the platform as one of:
CN1Constants.SMS_NOT_SUPPORTED (for desktop, tablet etc.),
CN1Constants.SMS_SEAMLESS (no UI interaction), CN1Constants.SMS_INTERACTIVE (with compose UI),
CN1Constants.SMS_BOTH .The sample below demonstrates the use case for this property: |
String[] |
getSupportedVirtualKeyboard()
Deprecated.
this method is only used in feature phones and has no modern equivalent
|
String |
getUdid()
Returns the UDID for devices that support it
|
ActionListener |
getVirtualKeyboardListener()
|
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 in a way that doesn't break event dispatch .
|
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 in a way that doesn't break event dispatch .
|
void |
invokeWithoutBlocking(Runnable r)
Invokes a Runnable with blocking disabled.
|
<T> T |
invokeWithoutBlockingWithResultSync(RunnableWithResultSync<T> r)
Invokes a RunnableWithResultSync with blocking disabled.
|
boolean |
isAllowMinimizing()
Allows a Codename One application to minimize without forcing it to the front whenever
a new dialog is poped up
|
boolean |
isAltGraphKeyDown()
Checks if the altgraph key is currently down.
|
boolean |
isAltKeyDown()
Checks if the alt key is currently down.
|
boolean |
isAutoFoldVKBOnFormSwitch()
Normally Codename One folds the VKB when switching forms this field allows us
to block that behavior.
|
boolean |
isBackgroundFetchSupported()
Checks to see if the current platform supports background fetch.
|
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)
Deprecated.
this isn't supported on most platforms
|
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 this method
returns true if the user denied permission to access contacts.
|
boolean |
isControlKeyDown()
Checks if the control key is currently down.
|
Boolean |
isDarkMode()
Returns true if the platform is in dark mode, null is returned for
unknown status
|
boolean |
isDatabaseCustomPathSupported() |
boolean |
isDesktop()
Returns true if this is a desktop application
|
boolean |
isEdt()
Returns true if we are currently in the event dispatch thread.
|
boolean |
isEnableAsyncStackTraces()
Checks if async stack traces are enabled.
|
boolean |
isFullScreenSupported()
Checks if this platform supports full-screen mode.
|
boolean |
isGalleryTypeSupported(int type)
Checks to see if the given gallery type is supported on the current platform.
|
boolean |
isGaussianBlurSupported()
Returns true if gaussian blur is supported on this platform
|
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!
|
boolean |
isInFullScreenMode()
Checks if the app is currently running in full-screen mode.
|
static boolean |
isInitialized()
This method returns true if the Display is initialized.
|
boolean |
isInTransition()
Returns true if the system is currently in the process of transitioning between
forms
|
boolean |
isJailbrokenDevice()
Returns true if this device is jailbroken or rooted, false if not or unknown.
|
boolean |
isMetaKeyDown()
Checks if the meta key is currently down.
|
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 |
isRightMouseButtonDown()
Checks if the last mouse press was a right click.
|
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 |
isScrollWheeling()
Checks is the scroll-wheel mouse is currently scrolling.
|
boolean |
isShiftKeyDown()
Checks if shift key is currently down.
|
boolean |
isSimulator()
Allows detecting development mode so debugging code and special cases can be used to simplify flow
|
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()
The name of this method is misleading due to it's legacy.
|
boolean |
isVirtualKeyboardShowing()
Deprecated.
this method was only relevant for feature phones.
You should use
TextArea.isEditing() instead. |
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)
Deprecated.
use scheduleLocalNotification instead
|
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 |
onCanInstallOnHomescreen(Runnable r)
A callback fired when you are allowed to prompt the user to install the app on their homescreen.
|
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 to pick an image or a video.
The method returns immediately and the response is sent asynchronously to the given ActionListener Object as the source value of the event (as a String) |
void |
openImageGallery(ActionListener response)
Deprecated.
see openGallery instead
|
void |
openNativeNavigationApp(double latitude,
double longitude)
Opens the native navigation app in the given coordinate.
|
void |
openNativeNavigationApp(String location)
Opens the native navigation app with the given search location
|
Database |
openOrCreate(String databaseName)
Opens a database or create one if not exists.
|
boolean |
platformUsesInputMode()
Checks if this platform uses input modes.
|
void |
playBuiltinSound(String soundIdentifier)
Deprecated.
this isn't supported on most platforms
|
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 |
postMessage(MessageEvent message)
Posts a message to the native platform.
|
boolean |
promptInstallOnHomescreen()
Prompts the user to install this app on their homescreen.
|
void |
refreshContacts()
Refreshes the native list of contacts on devices that require this see
ContactsManager.refresh() |
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()
Register to receive push notification, invoke this method once (ever) to receive push
notifications.
|
void |
registerPush(Hashtable metaData,
boolean noFallback)
Deprecated.
use
registerPush() the Android push id should be set with the build hint gcm.sender_id which will work for Chrome JavaScript builds too |
void |
registerPush(String id,
boolean noFallback)
Deprecated.
use
registerPush() the Android push id should be set with the build hint gcm.sender_id which will work for Chrome JavaScript builds too |
void |
registerVirtualKeyboard(VirtualKeyboardInterface vkb)
Deprecated.
this method is only used in feature phones and has no modern equivalent
|
void |
removeCompletionHandler(Media media,
Runnable onCompletion)
Removes onComplete callback from Media element.
|
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 |
removeMessageListener(ActionListener<MessageEvent> l)
Removes a listener from receiving messages from the native platform.
|
void |
removeVirtualKeyboardListener(ActionListener l)
Removes a listener for VirtualKeyboard hide/show events.
|
boolean |
requestFullScreen()
Try to enter full-screen mode if the platform supports it.
|
void |
restoreMinimizedApplication()
Restore the minimized application if minimization is supported by the platform
|
void |
restoreToBookmark()
Runs the last bookmark that was set using
setBookmark(java.lang.Runnable) |
void |
scheduleBackgroundTask(Runnable r)
Allows executing a background task in a separate low priority thread.
|
void |
scheduleLocalNotification(LocalNotification n,
long firstTime,
int repeat)
Schedules a local notification that will occur after the given time elapsed.
The sample below combines this with the geofence API to show a local notification when entering a radius with the app in the background: |
void |
sendMessage(String[] recipients,
String subject,
Message msg)
Send an email using the platform mail client.
The code below demonstrates sending a simple message with attachments using the devices native email 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, the code below demonstrates the logic
of detecting platform behavior for sending SMS.
|
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 |
setBookmark(Runnable bookmark)
Sets a bookmark that can restore the app to a particular state.
|
void |
setBuiltinSoundsEnabled(boolean enabled)
Allows muting/unmuting the builtin sounds easily
|
void |
setCommandBehavior(int commandBehavior)
Deprecated.
we recommend migrating to the
Toolbar API. When using the toolbar the command
behavior can't be manipulated |
void |
setCrashReporter(CrashReport crashReporter)
The crash reporter gets invoked when an uncaught exception is intercepted
|
void |
setDarkMode(Boolean darkMode)
Override the default dark mode setting
|
void |
setDefaultVirtualKeyboard(VirtualKeyboardInterface vkb)
Deprecated.
this method is only used in feature phones and has no modern equivalent
|
void |
setDragStartPercentage(int dragStartPercentage)
This method allows us to manipulate the drag started detection logic.
|
void |
setEnableAsyncStackTraces(boolean enableAsyncStackTraces)
Enables or disables async stack traces.
|
void |
setFramerate(int rate)
Indicates the maximum frames the API will try to draw every second
by default this is set to 10.
|
Timer |
setInterval(int period,
Runnable r)
Convenience method to schedule a task to run on the EDT after periodms
repeating every periodms.
|
void |
setLongPointerPressInterval(int v)
Long pointer press is invoked after the given interval, this allows making long press events shorter/longer
|
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 |
setPreferredBackgroundFetchInterval(int seconds)
Sets the preferred time interval between background fetches.
|
void |
setProjectBuildHint(String key,
String value)
Sets a build hint into the settings while overwriting any previous value.
|
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)
Deprecated.
this method isn't applicable in modern devices
|
void |
setShowVirtualKeyboard(boolean show)
Deprecated.
this method was only relevant for feature phones.
You should use
TextArea.startEditingAsync() or TextArea.stopEditing()
to control text field editing/VKB visibility |
void |
setThirdSoftButton(boolean thirdSoftButton)
Indicates whether the 3rd softbutton should be supported on this device
|
Timer |
setTimeout(int timeout,
Runnable r)
Convenience method to schedule a task to run on the EDT after timeoutms.
|
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 |
setVirtualKeyboardListener(ActionListener l)
|
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 textOrPath,
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
|
void |
startRemoteControl()
Starts the remote control service.
|
Thread |
startThread(Runnable r,
String name)
Deprecated.
confusing name use
createThread(java.lang.Runnable, java.lang.String) instead |
void |
stopEditing(Component cmp)
Allows us to stop editString on the given text component
|
void |
stopEditing(Component cmp,
Runnable onFinish)
Allows us to stop editString on the given text component or Form.
|
void |
stopRemoteControl()
Stops the remote control service.
|
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, notice that this might ignore the time value completely
on some OS's where this level of control isn't supported e.g.
|
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 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 void setBookmark(Runnable bookmark)
Runnable
that will be run when restoreToBookmark()
() } is called.
The primary purpose of this feature is live code refresh.
bookmark
- A Runnable
that can be run to restore the app to a particular point.public void restoreToBookmark()
setBookmark(java.lang.Runnable)
public static void init(Object m)
m
- platform specific object used by the implementationpublic static void deinitialize()
public static boolean isInitialized()
public static Display getInstance()
public PluginSupport getPluginSupport()
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 vibrate (might be ignored)public 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 stopRemoteControl()
RemoteControlListener
with the platform's remote control.
This is executed when a new listener is registered using MediaManager.setRemoteControlListener(com.codename1.media.RemoteControlListener)
public void startRemoteControl()
RemoteControlListener
with
the platform's remote control.
This is executed when the user registers a new listener using MediaManager.setRemoteControlListener(com.codename1.media.RemoteControlListener)
public Boolean isDarkMode()
public void setDarkMode(Boolean darkMode)
darkMode
- can be set to null to reset to platform defaultpublic boolean isEnableAsyncStackTraces()
callSerially(java.lang.Runnable)
calls will
be recorded, and logged in the case that there is an uncaught exception.
Currently this is only supported in the JavaSE/Simulator port.
setEnableAsyncStackTraces(boolean)
public void setEnableAsyncStackTraces(boolean enableAsyncStackTraces)
callSerially(java.lang.Runnable)
calls will
be recorded, and logged in the case that there is an uncaught exception.
Currently this is only supported in the JavaSE/Simulator port.
enableAsyncStackTraces
- True to enable async stack traces.isEnableAsyncStackTraces()
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 callSeriallyOnIdle(Runnable r)
r
- runnable (NOT A THREAD!) that will be invoked on the EDT serial to
the paint and key handling eventspublic String getLineSeparator()
public 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 boolean platformUsesInputMode()
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 boolean isInTransition()
public void onEditingComplete(Component c, String text)
c
- edited componenttext
- new text for the componentpublic void invokeWithoutBlocking(Runnable r)
invokeAndBlock(java.lang.Runnable)
from inside this Runnable,
it will result in a BlockingDisallowedException
being thrown.r
- Runnable to be run immediately.BlockingDisallowedException
- If invokeAndBlock(java.lang.Runnable)
is attempted
anywhere in the Runnable.public <T> T invokeWithoutBlockingWithResultSync(RunnableWithResultSync<T> r)
invokeAndBlock(java.lang.Runnable)
from inside this Runnable,
it will result in a BlockingDisallowedException
being thrown.r
- RunnableWithResultSync to be run immediately.BlockingDisallowedException
- If invokeAndBlock(java.lang.Runnable)
is attempted
anywhere in the Runnable.public void invokeAndBlock(Runnable r, boolean dropEvents)
r
- runnable (NOT A THREAD!) that will be invoked synchronously by this methoddropEvents
- indicates if the display should drop all events
while this runnable is runningBlockingDisallowedException
- if this method is called while blocking is disabled (i.e. we are running
inside a call to invokeWithoutBlocking(java.lang.Runnable)
on the EDT).public 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)
TextArea.startEditingAsync()
, TextArea.startEditing()
or Form.setEditOnShow(com.codename1.ui.TextArea)
.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)
TextArea.startEditingAsync()
, TextArea.startEditing()
or Form.setEditOnShow(com.codename1.ui.TextArea)
.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 void stopEditing(Component cmp, Runnable onFinish)
Form
, it will stop editing in any active
component on the form, and close the keyboard if it is opened.cmp
- the text field/text area componentonFinish
- invoked when editing stoppedpublic boolean minimizeApplication()
public boolean isMinimized()
public void restoreMinimizedApplication()
public boolean isControlKeyDown()
public boolean isMetaKeyDown()
public boolean isAltKeyDown()
public boolean isAltGraphKeyDown()
public boolean isRightMouseButtonDown()
public boolean isShiftKeyDown()
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 convertToPixels(float value, byte unitType)
value
- The value to convert, expressed in unitType.unitType
- The unit type. One of Style.UNIT_TYPE_DIPS
, Style.UNIT_TYPE_PIXELS
,
Style.UNIT_TYPE_REM
, Style.UNIT_TYPE_SCREEN_PERCENTAGE
, Style.UNIT_TYPE_VH
,
Style.UNIT_TYPE_VW
, Style.UNIT_TYPE_VMIN
, Style.UNIT_TYPE_VMAX
public int convertToPixels(float value, byte unitType, boolean horizontal)
value
- The value to convert, expressed in unitType.unitType
- The unit type. One of Style.UNIT_TYPE_DIPS
, Style.UNIT_TYPE_PIXELS
,
Style.UNIT_TYPE_REM
, Style.UNIT_TYPE_SCREEN_PERCENTAGE
, Style.UNIT_TYPE_VH
,
Style.UNIT_TYPE_VW
, Style.UNIT_TYPE_VMIN
, Style.UNIT_TYPE_VMAX
horizontal
- Whether screen percentage units should be based on horitonzal or vertical percentage.public int convertToPixels(float dipCount)
dipCount
- the dips that we will convert to pixelspublic 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)
TextArea.startEditingAsync()
or TextArea.stopEditing()
to control text field editing/VKB visibilityshow
- toggles the virtual keyboards visibilitypublic boolean isVirtualKeyboardShowing()
TextArea.isEditing()
instead.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 void setVirtualKeyboardListener(ActionListener l)
l
- the listenerpublic ActionListener getVirtualKeyboardListener()
public void addVirtualKeyboardListener(ActionListener l)
ActionEvent.getSource()
, with Boolean.TRUE on show, and Boolean.FALSE
on hide.
Note: Keyboard events may not be 100% reliable as they use heuristics on most platforms to guess when the keyboard is shown or hidden.
l
- The listener.removeVirtualKeyboardListener(com.codename1.ui.events.ActionListener)
public void removeVirtualKeyboardListener(ActionListener l)
ActionEvent.getSource()
, with Boolean.TRUE on show, and Boolean.FALSE
on hide.
Note: Keyboard events may not be 100% reliable as they use heuristics on most platforms to guess when the keyboard is shown or hidden.
l
- The listener.addVirtualKeyboardListener(com.codename1.ui.events.ActionListener)
public void fireVirtualKeyboardEvent(boolean show)
show
- public int getInvisibleAreaUnderVKB()
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 boolean isFullScreenSupported()
requestFullScreen()
, exitFullScreen()
, and isInFullScreenMode()
methods
to enter and exit full-screen - and query the current state.
Currently only desktop and Javascript builds support full-screen mode; And Javascript only supports this on certain browsers. See the MDN Fullscreen API docs for a list of browsers that support full-screen.
When running in the simulator, full-screen is only supported for the desktop skin.
requestFullScreen()
,
exitFullScreen()
,
isInFullScreenMode()
public boolean requestFullScreen()
Currently only desktop and Javascript builds support full-screen mode; And Javascript only supports this on certain browsers. See the MDN Fullscreen API docs for a list of browsers that support full-screen.
When running in the simulator, full-screen is only supported for the desktop skin.
exitFullScreen()
,
isInFullScreenMode()
,
isFullScreenSupported()
public boolean exitFullScreen()
Currently only desktop and Javascript builds support full-screen mode; And Javascript only supports this on certain browsers. See the MDN Fullscreen API docs for a list of browsers that support full-screen.
When running in the simulator, full-screen is only supported for the desktop skin.
requestFullScreen()
,
isInFullScreenMode()
,
isFullScreenSupported()
public boolean isInFullScreenMode()
requestFullScreen()
,
exitFullScreen()
,
isFullScreenSupported()
public void showNativeScreen(Object nativeFullScreenPeer)
nativeFullScreenPeer
- the native screen peerpublic boolean isAutoFoldVKBOnFormSwitch()
public void setAutoFoldVKBOnFormSwitch(boolean autoFoldVKBOnFormSwitch)
autoFoldVKBOnFormSwitch
- the autoFoldVKBOnFormSwitch to setpublic int getCommandBehavior()
Toolbar
API. When using the toolbar the command
behavior can't be manipulatedpublic void postMessage(MessageEvent message)
The Javascript port will dispatch the message on the window object as a custom DOM event named 'cn1outbox', with the event data containing a 'detail' key with the message, and a 'code' key with the code.
message
- The message.public void addMessageListener(ActionListener<MessageEvent> l)
In the JavaScript port, listeners will be notified when DOM events named 'cn1inbox' are received on the window object. The event data 'detail' key will be the source of the message, and the 'code' key will be the source of the code.
l
- The listener.public void removeMessageListener(ActionListener<MessageEvent> l)
l
- The listener.public void dispatchMessage(MessageEvent evt)
evt
- addMessageListener(com.codename1.ui.events.ActionListener)
,
removeMessageListener(com.codename1.ui.events.ActionListener)
public void setCommandBehavior(int commandBehavior)
Toolbar
API. When using the toolbar the command
behavior can't be manipulatedcommandBehavior
- 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)
Returns true if executing this URL should work, returns false if it will not and null if this is unknown.
url
- the url that would be executedpublic void execute(String url)
Executes the given URL on the native platform
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 String getDensityStr()
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 Rectangle getDisplaySafeArea(Rectangle rect)
rect
- Out parameter that will store the display safe area.Form.getSafeArea()
public 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 AsyncResource<Media> createMediaAsync(String uri, boolean video, Runnable onCompletion)
uri
- the platform specific location for the soundonCompletion
- invoked when the audio file finishes playing, may be nullpublic void addCompletionHandler(Media media, Runnable onCompletion)
media
- The media to add the callback to.onCompletion
- The callback that will run on the EDT when the playback completes.removeCompletionHandler(com.codename1.media.Media, java.lang.Runnable)
public void removeCompletionHandler(Media media, Runnable onCompletion)
media
- The media element.onCompletion
- The callback.addCompletionHandler(com.codename1.media.Media, java.lang.Runnable)
public 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 AsyncResource<Media> createMediaAsync(InputStream stream, String mimeType, Runnable onCompletion)
public 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()
Since version 6.0, orientation lock is supported in Javascript builds in some browsers. For a full list of browsers the support locking orientation, see the MDN Lock Orientation docs.
NOTE: In Javascript builds, orientation lock is only supported if the app is running in full-screen mode. If the app is not
currently in full-screen mode, then canForceOrientation()
will return false and lockOrientation(boolean)
will do nothing.
lockOrientation(boolean)
,
unlockOrientation()
public void lockOrientation(boolean portrait)
Since version 6.0, orientation lock is supported in Javascript builds in some browsers. For a full list of browsers the support locking orientation, see the MDN Lock Orientation docs.
NOTE: In Javascript builds, orientation lock is only supported if the app is running in full-screen mode. If the app is not
currently in full-screen mode, then canForceOrientation()
will return false and lockOrientation(boolean)
will do nothing.
portrait
- true to lock to portrait mode, false to lock to landscape modeunlockOrientation()
,
canForceOrientation()
public void unlockOrientation()
Since version 6.0, orientation lock is supported in Javascript builds in some browsers. For a full list of browsers the support locking orientation, see the MDN Lock Orientation docs.
NOTE: In Javascript builds, orientation lock is only supported if the app is running in full-screen mode. If the app is not
currently in full-screen mode, then canForceOrientation()
will return false and lockOrientation(boolean)
will do nothing.
lockOrientation(boolean)
,
canForceOrientation()
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 captureAudio(MediaRecorderBuilder recordingOptions, ActionListener response)
recordingOptions
- Audio recording options.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 captureVideo(VideoCaptureConstraints constraints, ActionListener response)
captureVideo(com.codename1.ui.events.ActionListener)
, except that it
attempts to impose constraints on the capture. Constraints include width, height,
and max length. Not all platforms support capture constraints. Use the VideoCaptureConstraints.isSupported()
to see if a constraint is supported. If constraints are not supported at all, then this method
will fall back to calling captureVideo(com.codename1.ui.events.ActionListener)
.constraints
- Capture constraints to use.response
- a callback Object to retrieve the file pathCapture.captureVideo(com.codename1.capture.VideoCaptureConstraints, com.codename1.ui.events.ActionListener)
public 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)
Opens the device gallery to pick an image or a video.
The method returns immediately and the response is sent asynchronously
to the given ActionListener Object as the source value of the event (as a String)
E.g. within the callback action performed call you can use this code: String path = (String) evt.getSource();
.
A more detailed sample of picking a video file can be seen here:
Version 5.0 and higher support multi-selection (i.e. the types CN1Constants.GALLERY_IMAGE_MULTI
, CN1Constants.GALLERY_VIDEO_MULTI
, and CN1Constants.GALLERY_ALL_MULTI
). When using one of the multiselection
types, the source of the ActionEvent will be a String[]
, containing the paths of the selected elements, or null if the user cancelled the dialog.
Currently (version 5.0 and higher), all platforms support the types CN1Constants.GALLERY_IMAGE
, CN1Constants.GALLERY_VIDEO
, CN1Constants.GALLERY_ALL
, CN1Constants.GALLERY_IMAGE_MULTI
, CN1Constants.GALLERY_VIDEO_MULTI
, CN1Constants.GALLERY_ALL_MULTI
. On iOS,
multi-selection requires a deployment target of iOS 8.0 or higher, so it is disabled by default. You can enable multi-selection on iOS, by adding the ios.enableGalleryMultiselect=true build hint. This
build hint will be added automatically for you if you run your app in the simulator, and it calls openGallery() with one of the multiselect gallery types.
response
- a callback Object to retrieve the file path For multiselection types (CN1Constants.GALLERY_IMAGE_MULTI
, CN1Constants.GALLERY_VIDEO_MULTI
, and CN1Constants.GALLERY_ALL_MULTI
), the source
of the ActionEvent sent this callback will be a String[]. For other types, it will be a String. If the dialog was cancelled, it will be null.type
- one of the following CN1Constants.GALLERY_IMAGE
, CN1Constants.GALLERY_VIDEO
, CN1Constants.GALLERY_ALL
, CN1Constants.GALLERY_IMAGE_MULTI
, CN1Constants.GALLERY_VIDEO_MULTI
, CN1Constants.GALLERY_ALL_MULTI
.RuntimeException
- if this feature failed or unsupported on the platform. Use isGalleryTypeSupported(int)
to check if the type is supported before calling this method.To see if a type is supported on the current platform.
public boolean isGalleryTypeSupported(int type)
type
- one of the following CN1Constants.GALLERY_IMAGE
, CN1Constants.GALLERY_VIDEO
, CN1Constants.GALLERY_ALL
, CN1Constants.GALLERY_IMAGE_MULTI
, CN1Constants.GALLERY_VIDEO_MULTI
, CN1Constants.GALLERY_ALL_MULTI
.openGallery(com.codename1.ui.events.ActionListener, int)
public String getPlatformName()
public String[] getPlatformOverrides()
public void sendMessage(String[] recipients, String subject, Message msg)
Send an email using the platform mail client.
The code below demonstrates sending a simple message with attachments using the devices
native email client:
recipients
- array of e-mail addressessubject
- e-mail subjectmsg
- the Message to sendpublic void dial(String phoneNumber)
phoneNumber
- public int getSMSSupport()
Indicates the level of SMS support in the platform as one of:
CN1Constants.SMS_NOT_SUPPORTED
(for desktop, tablet etc.),
CN1Constants.SMS_SEAMLESS
(no UI interaction), CN1Constants.SMS_INTERACTIVE
(with compose UI),
CN1Constants.SMS_BOTH
.
The sample below demonstrates the use case for this property:
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
Sends a SMS message to the given phone number, the code below demonstrates the logic of detecting platform behavior for sending SMS.
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
getSMSSupport()
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 void openNativeNavigationApp(String location)
location
- the location to search for in the native navigation mappublic 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)
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. See isGetAllContactsFast for
information.
The sample below demonstrates listing all the contacts within the device with their photos
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 String[] getLinkedContactIds(Contact c)
c
- The contact whose "linked" contacts are to be retrieved.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)
This method returns a Contact by the contact id and fills it's data
according to the given flags.
The sample below demonstrates listing all the contacts within the device with their photos
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 familyNameofficePhone
- the Contact work phone or nullhomePhone
- the Contact home phone or nullcellPhone
- 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)
Since 6.0, there is native sharing support in the Javascript port using the navigator.share API. Currently (2019) this is only supported on Chrome for Android, and will only work if the app is accessed over https:.
toShare
- String to share.public void share(String text, String image, String mimeType)
Since 6.0, there is native sharing support in the Javascript port using the navigator.share API. Currently (2019) this is only supported on Chrome for Android, and will only work if the app is accessed over https:.
text
- String to share.image
- file path to the image or nullmimeType
- type of the image or null if no image to sharepublic void share(String textOrPath, String image, String mimeType, Rectangle sourceRect)
Since 6.0, there is native sharing support in the Javascript port using the navigator.share API. Currently (2019) this is only supported on Chrome for Android, and will only work if the app is accessed over https:.
Since 8.0, you can share files using using the file path in the text parameter. The file must exist in file system storage, and
you must define the appropriate mimeType in the mimeType parameter. E.g. share("file:/.../myfile.pdf", null, "application.pdf")
textOrPath
- String to share, or path to file to share.image
- file path to the image or nullmimeType
- type of the image or file. null if just sharing textsourceRect
- 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()
The localization manager allows adapting values for display in different locales thru parsing and formatting
capabilities (similar to JavaSE's DateFormat/NumberFormat). It also includes language/locale/currency
related API's similar to Locale/currency API's from JavaSE.
The sample code below just lists the various capabilities of the API:
public void registerPush(String id, boolean noFallback)
registerPush()
the Android push id should be set with the build hint gcm.sender_id
which will work for Chrome JavaScript builds tooid
- 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)
registerPush()
the Android push id should be set with the build hint gcm.sender_id
which will work for Chrome JavaScript builds toometaData
- 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 registerPush()
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(MediaRecorderBuilder builder) throws IOException
builder
- A MediaRecorderBuilderIOException
MediaRecorderBuilder.build()
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
isDatabaseCustomPathSupported()
this method can optionally accept a file path.databaseName
- the name of the databaseIOException
- if database cannot be createdpublic boolean isDatabaseCustomPathSupported()
public 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)
databaseName
- the name of the database with out / or path
elements e.g. mydatabase.db
public void setPollingFrequency(int freq)
freq
- the frequency in millisecondspublic Thread createThread(Runnable r, String name)
r
- runnable to run, NOTICE the thread MUST be explicitly started!name
- the name for the threadpublic Thread startThread(Runnable r, String name)
createThread(java.lang.Runnable, java.lang.String)
insteadr
- 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 boolean isScrollWheeling()
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 setpublic void setLongPointerPressInterval(int v)
v
- time in millisecondspublic int getLongPointerPressInterval()
public void scheduleLocalNotification(LocalNotification n, long firstTime, int repeat)
Schedules a local notification that will occur after the given time elapsed.
The sample below combines this with the geofence API to show a local notification
when entering a radius with the app in the background:
n
- The notification to schedule.firstTime
- time in milliseconds when to schedule the notificationrepeat
- repeat one of the following: REPEAT_NONE, REPEAT_FIFTEEN_MINUTES,
REPEAT_HALF_HOUR, REPEAT_HOUR, REPEAT_DAY, REPEAT_WEEKpublic void cancelLocalNotification(String notificationId)
notificationId
- LocalNotification
public void setPreferredBackgroundFetchInterval(int seconds)
This method must be called in order to activate background fetch.>
Note: If the platform doesn't support background fetch (i.e. isBackgroundFetchSupported()
returns false
,
then this method does nothing.
seconds
- The time interval in seconds.isBackgroundFetchSupported()
,
()
,
BackgroundFetch
public int getPreferredBackgroundFetchInterval(int seconds)
isBackgroundFetchSupported()
,
setPreferredBackgroundFetchInterval(int)
,
BackgroundFetch
public boolean isBackgroundFetchSupported()
setPreferredBackgroundFetchInterval(int)
,
()
,
BackgroundFetch
public boolean isSimulator()
public Media createBackgroundMedia(String uri) throws IOException
uri
- the uri of the media can start with jar://, file://, http://
(can also use rtsp:// if supported on the platform)IOException
- if creation of media from the given URI has failedpublic AsyncResource<Media> createBackgroundMediaAsync(String uri)
uri
- the uri of the media can start with jar://, file://, http://
(can also use rtsp:// if supported on the platform)public Image gaussianBlurImage(Image image, float radius)
image
- the image to blurradius
- the radius to be used in the algorithmpublic boolean isGaussianBlurSupported()
public void refreshContacts()
ContactsManager.refresh()
public boolean isJailbrokenDevice()
public Map<String,String> getProjectBuildHints()
public void setProjectBuildHint(String key, String value)
key
- the build hint without the codename1.arg. prefixvalue
- the value for the hintpublic boolean canInstallOnHomescreen()
Best practice is to use onCanInstallOnHomescreen(java.lang.Runnable)
to be notified
when you are allowed to prompt the user for installation. Then call promptInstallOnHomescreen()
inside that method - or sometime after.
onCanInstallOnHomescreen(()->{
if (canInstallOnHomescreen()) {
if (promptInstallOnHomescreen()) {
// User accepted installation
} else {
// user rejected installation
}
}
});
https://developers.google.com/web/fundamentals/app-install-banners/promptInstallOnHomescreen()
,
onCanInstallOnHomescreen(java.lang.Runnable)
public boolean promptInstallOnHomescreen()
canInstallOnHomescreen()
,
onCanInstallOnHomescreen(java.lang.Runnable)
public void onCanInstallOnHomescreen(Runnable r)
r
- Runnable that will be run when/if you are permitted to prompt the user to install
the app on their homescreen.public Image captureScreen()
public Timer setTimeout(int timeout, Runnable r)
timeout
- The timeout in milliseconds.r
- The task to run.setInterval(int, java.lang.Runnable)
public Timer setInterval(int period, Runnable r)
period
- The delay and repeat in milliseconds.r
- The runnable to run on the EDT.setTimeout(int, java.lang.Runnable)
public BrowserComponent getSharedJavascriptContext()
BrowserComponent
API.
When running on other platforms, this shared context will be an off-screen browser component.
Sample code allowing user to execute arbitrary Javascript code inside the shared context: