public class GPSView extends Container implements TimerListener
add(gps = new GPSView(1000),LEFT,TOP);See the tc.samples.io.device.GPSTest. On Android, don't forget to turn on the GPS, going to Settings / Security & Location / Enable GPS satellites. The other platforms may require that as well. If the GPS fails connecting to the satellites, and the phone has signal, you can use the cell tower location as a rough location. The precision is vary between 50m to 3km, depending where the phone is. You can get the latitude and longitude using CellInfo.toCoordinates. This class uses the GPS class to show the values on Labels. You can use the GPS class standalone if you wish. See the tc.samples.maps.GoogleMaps sample.
GPS,
CellInfo.toCoordinates()Control.TranslucentShape| Modifier and Type | Field and Description |
|---|---|
GPS |
gps
Class used to retrieve the GPS coordinates.
|
static java.lang.String |
LAT_LOW_SIGNAL
String that will be printed with there longitude can't be acquired.
|
static java.lang.String |
LON_LOW_SIGNAL
String that will be printed with there longitude can't be acquired.
|
alwaysEraseBackground, BACKGROUND_CYLINDRIC_SHADED, BACKGROUND_SHADED, BACKGROUND_SHADED_INV, BACKGROUND_SOLID, backgroundStyle, BORDER_LOWERED, BORDER_NONE, BORDER_RAISED, BORDER_ROUNDED, BORDER_SIMPLE, BORDER_TOP, borderColor, borderRadius, children, controlFound, finishedStart, ignoreOnAddAgain, ignoreOnRemove, insets, lastH, lastScreenWidth, lastW, lastX, lastY, numChildren, started, tabOrder, tail, TRANSITION_TIMEAFTER, alphaValue, appId, appObj, asContainer, asWindow, backColor, BEFORE, BOTTOM, BOTTOM_OF, BRIGHTER_BACKGROUND, callListenersOnAllTargets, CENTER, CENTER_OF, clearValueInt, clearValueStr, DARKER_BACKGROUND, DP, effect, enableUpdateScreen, esce, eventsEnabled, FILL, fillColor, FIT, floating, fm, fmH, focusHandler, focusLess, focusOnPenDown, focusTraversable, font, FONTSIZE, foreColor, height, ignoreInsets, isHighlighting, isTablet, KEEP, keepDisabled, keepEnabled, LEFT, next, nextTabControl, npParts, offscreen, offscreen0, onEventFirst, parent, PARENTSIZE, PARENTSIZEMAX, PARENTSIZEMIN, PREFERRED, prev, RANGE, repositionAllowed, RIGHT, RIGHT_OF, SAME, SCREENSIZE, SCREENSIZEMAX, SCREENSIZEMIN, setFont, setH, setRel, setW, setX, SETX_NOT_SET, setY, tempW, textShadowColor, TOP, translucentShape, transparentBackground, uiAdjustmentsBasedOnFontHeightIsSupported, uiAndroid, UICONST, uiFlat, uiHolo, uiMaterial, uiVista, visible, width, WILL_RESIZE, x, y| Constructor and Description |
|---|
GPSView()
Constructs a GPS using a read interval of 2 seconds.
|
GPSView(GPS gps,
int readInterval)
Constructs a GPSView using the given GPS as input.
|
GPSView(int readInterval)
Constructs a GPSView using the given read interval.
|
GPSView(PortConnector sp,
int readInterval)
Constructs a GPSView using the given PortConnector and read interval.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getPreferredHeight()
Returns the preferred height of this control.
|
int |
getPreferredWidth()
Returns the preferred width of this control.
|
void |
initUI()
Called to initialize the User Interface of this container.
|
protected void |
onColorsChanged(boolean colorsChanged)
Called after a setEnabled, setForeColor and setBackColor and when a control has
been added to a Container.
|
protected void |
onFontChanged()
Called after a setFont
|
void |
retrieveGPSData()
Retrieves the GPS data and updates the fields with it.
|
void |
stop()
Removes the timer and stops the GPS.
|
void |
timerTriggered(TimerEvent e)
A TRIGGERED event was dispatched.
|
add, add, add, add, add, broadcastEvent, clear, fillBackground, findChild, findNearestChild, findNextFocusControl, getBorderRadius, getBorderStyle, getChildren, getChildrenCount, getClientRect, getClientRect, getFirstChild, getFocusableControls, getInsets, incLastX, incLastY, isPressed, moveFocusToNextControl, moveFocusToNextEditable, onAddAgain, onPaint, onRemove, onSwapFinished, paintChildren, remove, removeAll, resize, resizeHeight, resizeWidth, setBorderRadius, setBorderStyle, setEnabled, setFocusTraversable, setHighlighting, setInsets, setPressColor, setPressed, swapToTopmostWindow_onEvent, addEnabledStateListener, addFocusListener, addFontChangeHandler, addGridListener, addHandler, addHighlightListener, addKeyListener, addListContainerListener, addMouseListener, addMultiTouchListener, addPenListener, addPressListener, addPushNotificationListener, addSizeChangeHandler, addTimer, addTimer, addTimerListener, addValueChangeHandler, addWindowListener, bringToFront, changeHighlighted, contains, drawTranslucentBackground, getAbsoluteRect, getBackColor, getDoEffect, getEffectH, getEffectW, getEffectX, getEffectY, getEventListeners, getFont, getForeColor, getGap, getGraphics, getHeight, getNext, getParent, getParentWindow, getPos, getPressedEvent, getPrev, getRect, getSize, getTextShadowColor, getWidth, getX, getX2, getY, getY2, hadParentScrolled, handleGeographicalFocusChangeKeys, hasFocus, internalSetEnabled, intXYWH, isActionEvent, isChildOf, isDisplayed, isEnabled, isFloating, isInsideOrNear, isObscured, isTopMost, isVisible, isVisibleAndInside, onBoundsChanged, onEvent, onWindowPaintFinished, post, postEvent, postPressedEvent, releaseScreenShot, removeEnabledStateListener, removeFocusListener, removeGridListener, removeHandler, removeHighlightListener, removeKeyListener, removeListContainerListener, removeMouseListener, removeMultiTouchListener, removePenListener, removePressListener, removePushNotificationListener, removeTimer, removeTimerListener, removeWindowListener, repaint, repaintNow, reposition, reposition, repositionChildren, requestFocus, resetSetPositions, resetStyle, safeRepaintNow, safeUpdateScreen, sendToBack, setBackColor, setBackForeColors, setDoEffect, setFloating, setFocusLess, setFont, setForeColor, setNinePatch, setNinePatch, setRect, setRect, setRect, setRect, setSet, setTextShadowColor, setTranslucent, setVisible, showTip, takeInitialScreenShot, takeScreenShot, translateFromOrigin, uiStyleChanged, updateScreen, updateTemporary, willOpenKeyboardpublic static java.lang.String LON_LOW_SIGNAL
public static java.lang.String LAT_LOW_SIGNAL
public GPS gps
public GPSView()
throws IOException
IOExceptionpublic GPSView(int readInterval)
throws IOException
readInterval - The interval used to fetch data, in milliseconds. A ControlEvent.PRESSED is posted each time the TRIGGERED event occurs.IOExceptionpublic GPSView(PortConnector sp, int readInterval) throws IOException
IOExceptionpublic GPSView(GPS gps, int readInterval) throws IOException
IOExceptionpublic void initUI()
Containerpublic void timerTriggered(TimerEvent e)
TimerListenertimerTriggered in interface TimerListenerTimerEventpublic void stop()
throws IOException
IOExceptionpublic void retrieveGPSData()
public int getPreferredWidth()
ControlgetPreferredWidth in class Controlpublic int getPreferredHeight()
ControlgetPreferredHeight in class Controlprotected void onColorsChanged(boolean colorsChanged)
ControlonColorsChanged in class Containerprotected void onFontChanged()
ControlonFontChanged in class Control