public class Device extends Object implements VmConstants
Modifier and Type | Field and Description |
---|---|
static int |
BATTERY_AC
This is a possible parameter for getBatteryState().
|
static int |
BATTERY_BACKUP
This is a possible parameter for getBatteryState().
|
static int |
BATTERY_MAIN
This is a possible parameter for getBatteryState().
|
static int |
BATTERY_OPTION_FLAGS |
static int |
BATTERY_OPTION_POWER_LEFT |
static int |
BATTERY_STATE_UNKNOWN
This is a possible return value for getBatteryState.
|
static int |
GUI_CAN_BEEP
A possible return value for getGUICapabilities().
|
static int |
GUI_CAN_DISPLAYTEXT
A possible return value for getGUICapabilities().
|
static int |
GUI_CAN_FLASHMESSAGE
A possible return value for getGUICapabilities().
|
static int |
GUI_CAN_HAVE_TASKBARICON
A possible return value for getGUICapabilities().
|
static int |
GUI_CAN_MESSAGEBOX
A possible return value for getGUICapabilities().
|
static int |
IDABORT
A possible return value from messageBox()
|
static int |
IDCANCEL
A possible return value from messageBox()
|
static int |
IDIGNORE
A possible return value from messageBox()
|
static int |
idleTimeOut
When the preventIdleState method is called a Thread is started
that calls resetIdleState() at an interval determined by this value
measured in milliseconds.
|
static int |
IDNO
A possible return value from messageBox()
|
static int |
IDOK
A possible return value from messageBox()
|
static int |
IDRETRY
A possible return value from messageBox()
|
static int |
IDYES
A possible return value from messageBox()
|
static int |
MB_MASK_FOR_TYPE |
static int |
MB_OPTION_APPLMODAL
A type for use with messageBox()
|
static int |
MB_OPTION_ICONASTERISK
Can be OR'ed with the MB_XXX types for messageBox()
|
static int |
MB_OPTION_ICONERROR
Can be OR'ed with the MB_XXX types for messageBox()
|
static int |
MB_OPTION_ICONEXCLAMATION
Can be OR'ed with the MB_XXX types for messageBox()
|
static int |
MB_OPTION_ICONHAND
Can be OR'ed with the MB_XXX types for messageBox()
|
static int |
MB_OPTION_ICONINFORMATION
Can be OR'ed with the MB_XXX types for messageBox()
|
static int |
MB_OPTION_ICONQUESTION
Can be OR'ed with the MB_XXX types for messageBox()
|
static int |
MB_OPTION_ICONSTOP
Can be OR'ed with the MB_XXX types for messageBox()
|
static int |
MB_OPTION_ICONWARNING
Can be OR'ed with the MB_XXX types for messageBox()
|
static int |
MB_OPTION_SYSTEMMODAL
A type for use with messageBox()
|
static int |
MB_OPTION_TASKMODAL
A type for use with messageBox()
|
static int |
MB_TYPE_OK
A type for use with messageBox()
|
static int |
MB_TYPE_OKCANCEL
A type for use with messageBox()
|
static int |
MB_TYPE_YESNO
A type for use with messageBox()
|
static int |
MB_TYPE_YESNOCANCEL
A type for use with messageBox()
|
static int |
ROTATION_180 |
static int |
ROTATION_270 |
static int |
ROTATION_90 |
static int |
ROTATION_NONE |
Class |
yieldToEventsClass
If this is set to a class
|
BUSY_CURSOR, COPY_MULTIPLE_CURSOR, COPY_SINGLE_CURSOR, CROSS_CURSOR, DEFAULT_CURSOR, DONT_DROP_CURSOR, DRAG_MULTIPLE_CURSOR, DRAG_SINGLE_CURSOR, GET_PARAMATER_SIP_BUTTON_HEIGHT, GET_PARAMATER_SOFTKEY_BAR_HEIGHT, GET_SET_PARAMATER_PAINT_BUFFER_TIME, GET_SET_PARAMATER_PEN_MOVE_BUFFER_TIME, GET_SET_PARAMATER_RESIZE_BUFFER_TIME, HAND_CURSOR, IBEAM_CURSOR, INVISIBLE_CURSOR, JAR_RESOURCE_ID, LEFT_RIGHT_CURSOR, MOVE_CURSOR, NO_CURSOR, RESIZE_CURSOR, SET_USE_SIP, SIMULATE_SIP, TIMER_TICK, TURN_OFF_VM_FLAG_BITS, TURN_ON_VM_FLAG_BITS, UP_DOWN_CURSOR, VM_CLASS_MEMORY, VM_FILE_SEPARATOR, VM_FLAG_HAS_BACK_BUTTON, VM_FLAG_HAS_SOFT_KEYS, VM_FLAG_HAS_SOFTKEY_MENU_BUTTON, VM_FLAG_HIDDEN_SOFTKEYS, VM_FLAG_IS_APPLET, VM_FLAG_IS_MOBILE, VM_FLAG_IS_MONOCHROME, VM_FLAG_IS_ZAURUS_EVM, VM_FLAG_LOAD_FAKE_FILE, VM_FLAG_LOW_MEMORY, VM_FLAG_MAXIMIZE_APPS, VM_FLAG_NO_CR, VM_FLAG_NO_GUI, VM_FLAG_NO_KEYBOARD, VM_FLAG_NO_MOUSE_POINTER, VM_FLAG_NO_PEN, VM_FLAG_NO_VISIBLE_WINDOW, VM_FLAG_NO_WINDOWS, VM_FLAG_SIP_BUTTON_ALWAYS_SHOWN, VM_FLAG_SIP_BUTTON_ON_SCREEN, VM_FLAG_SIP_DISABLED, VM_FLAG_SLOW_MACHINE, VM_FLAG_SYSTEM_FONTS_ONLY, VM_FLAG_USE_NATIVE_TEXT_INPUT, VM_FLAG_USE_SOFT_KEYPAD, VM_FLAG_USING_CLASSES, VM_FLAGS, VM_NUM_OBJECTS, VM_NUM_THREADS, VM_OBJECT_MEMORY, VM_PATH_SEPARATOR, WAIT_CURSOR
Modifier and Type | Method and Description |
---|---|
static void |
checkNoNativeMethod(Throwable t)
This is used to check if the thrown exception indicates that native methods
are not allowed.
|
static IConsole |
createConsole(String title,
int iconsoleOptions,
int maxLines) |
static DeviceIcon |
createIcon(ImageData[] images,
int preferredImage)
Create a DeviceIcon for use with Windows and Taskbars and other
OS functions.
|
static void |
createShortcut(String targetExecutable,
String arguments,
String shortcutName) |
static ITaskbarEntry |
createTaskbarEntry() |
static void |
flashMessage(String message,
int howLongInMillis) |
static int |
getBatteryState(int battery)
Return the state of the battery.
|
static int |
getGUICapabilities()
Get the GUI capabilities of the currently running VM.
|
static String |
getPathToVm()
Get the path to the Eve VM on this system or null if it cannot be determined.
|
static int |
getScreenRotation() |
static ITaskbarEntry |
getTaskbarEntry(String title)
Get a TaskBar entry (an icon in the system tray on most systems) that can have
an icon and text tip displayed.
|
static String[] |
getVmCommandLine(String arguments)
Return a path to the native VM.
|
static boolean |
hasFlag(int vmFlag) |
static boolean |
hasGUI() |
static boolean |
hasPendingEvents() |
static boolean |
isMobile() |
static ImageData |
loadPicture(Object source)
This will attempt to load an Image/Picture if the eve.fx package is present.
|
static boolean |
messageBeep(int whichBeep)
Note - you should usually use Sound.beep() produce a beep.
|
static int |
messageBox(String title,
String text,
int type) |
static boolean |
preloadVm(boolean onOrOff) |
static boolean |
preventIdleState(boolean startPrevent)
Enter or leave a period where you wish for the Device to not power down due
to being in an idle state.
|
static boolean |
resetIdleState()
Reset the devices countdown to idle state - thereby preventing the device
from entering an idle state until the device's countdown completes again.
|
static ImageData |
scaleImage(ImageData src,
int newWidth,
int newHeight) |
static void |
setScreenRotation(int rotation) |
static void |
setThreadIsEventHandler() |
static DeviceIcon |
toDeviceIcon(Object image)
Create a device icon from a variety of objects.
|
static boolean |
tryMessageBox(String title,
String text,
boolean showTitleOnOutput)
Display a message - either as a MessageBox or on standard output if no MessageBox
is possible.
|
static void |
yield() |
static void |
yieldToEvents(int max) |
public Class yieldToEventsClass
public static final int GUI_CAN_MESSAGEBOX
public static final int GUI_CAN_FLASHMESSAGE
public static final int GUI_CAN_HAVE_TASKBARICON
public static final int GUI_CAN_DISPLAYTEXT
public static final int GUI_CAN_BEEP
public static final int IDABORT
public static final int IDCANCEL
public static final int IDIGNORE
public static final int IDNO
public static final int IDOK
public static final int IDRETRY
public static final int IDYES
public static final int MB_OPTION_APPLMODAL
public static final int MB_OPTION_ICONASTERISK
public static final int MB_OPTION_ICONHAND
public static final int MB_OPTION_ICONERROR
public static final int MB_OPTION_ICONEXCLAMATION
public static final int MB_OPTION_ICONINFORMATION
public static final int MB_OPTION_ICONQUESTION
public static final int MB_OPTION_ICONSTOP
public static final int MB_OPTION_ICONWARNING
public static final int MB_TYPE_OK
public static final int MB_TYPE_OKCANCEL
public static final int MB_OPTION_SYSTEMMODAL
public static final int MB_OPTION_TASKMODAL
public static final int MB_TYPE_YESNO
public static final int MB_TYPE_YESNOCANCEL
public static final int MB_MASK_FOR_TYPE
public static int idleTimeOut
public static final int BATTERY_MAIN
public static final int BATTERY_BACKUP
public static final int BATTERY_AC
public static final int BATTERY_OPTION_POWER_LEFT
public static final int BATTERY_OPTION_FLAGS
public static final int BATTERY_STATE_UNKNOWN
public static final int ROTATION_NONE
public static final int ROTATION_90
public static final int ROTATION_180
public static final int ROTATION_270
public static void checkNoNativeMethod(Throwable t)
You would use it in your code like this:
private static boolean haveNative = true; private native int myNativeMethod(Object parameter) throws IOException; public int myMethod(Object parameter) throws IOException { int result = 0; if (haveNative) try{ result = myNativeMethod(parameter); }catch(IOException e){ // I must handle all the expected exceptions first. throw e; }catch(Throwable t){ Device.checkNoNativeMethod(t); haveNative = false; // I won't attempt a native method again. } // if (!haveNative){ // Now I must use a non-native way of doing the method. //result = something; } return result; }
t
- the Throwable thrown.public static int getGUICapabilities()
public static boolean isMobile()
public static boolean hasFlag(int vmFlag)
public static boolean hasGUI()
public static DeviceIcon createIcon(ImageData[] images, int preferredImage)
However if the underlying system does not support multiple images in an icon then the preferredImage should specify which one to use.
images
- the images making up the icon.preferredImage
- the index of the preferred image.public static DeviceIcon toDeviceIcon(Object image)
image
- this can be: a DeviceIcon - in which case it is returned as is. an ImageData - in which case a DeviceIcon is created from it. a String - in which case it is converted to an ImageData via loadPicture() and then converted to a DeviceIcon. a FormattedDataSource - in which case it is converted to an ImageData via loadPicture() and then converted to a DeviceIcon. an Array of ImageData, String or FormattedDataSource objects. In which case they are all converted to an array of ImageData using loadPicture
public static ITaskbarEntry getTaskbarEntry(String title)
title
- a title for the entry - which may or may not be displayed.listener
- an optional listener to listen to events from the TaskbarEntry.
Usually this is will be an event that indicates when the icon is clicked or
double clicked.public static int messageBox(String title, String text, int type) throws UnsupportedOperationException
UnsupportedOperationException
public static void flashMessage(String message, int howLongInMillis) throws UnsupportedOperationException
UnsupportedOperationException
public static boolean tryMessageBox(String title, String text, boolean showTitleOnOutput)
title
- the title for the MessageBox.text
- the main text for the message.showTitleOnOutput
- if the message must be output on standard output, then
if this is true the title followed by a ':' is output before the text. Otherwise
only the text is output.public static ImageData loadPicture(Object source)
source
- either the name of the image or a eve.util.FormattedDataSourcepublic static boolean messageBeep(int whichBeep)
whichBeep
- this should be one of the MB_ICONXXX values. On a Linux
system this will usually just beep on the speaker.public static String getPathToVm()
public static String[] getVmCommandLine(String arguments) throws IOException
arguments
- IOException
public static void createShortcut(String targetExecutable, String arguments, String shortcutName) throws IOException
IOException
public static boolean preloadVm(boolean onOrOff)
public static boolean resetIdleState()
public static boolean preventIdleState(boolean startPrevent)
startPrevent
- true to enter the protected period, false to leave it.public static int getBatteryState(int battery)
battery
- one of the BATTERY_XXX OR'ed with one of the BATTERY_OPTION_XXX flags. A value of zero
defaults to returning the power left on the main battery.public static ITaskbarEntry createTaskbarEntry()
public static void yield()
public static void setThreadIsEventHandler()
public static void yieldToEvents(int max)
public static boolean hasPendingEvents()
public static void setScreenRotation(int rotation)
public static int getScreenRotation()