de.enough.polish.util
Class DeviceControl

java.lang.Object
  extended by java.lang.Thread
      extended by de.enough.polish.util.DeviceControl
All Implemented Interfaces:
Runnable

public class DeviceControl
extends Thread

Controls backlight and vibration in an device-independent manner.

Copyright Enough Software 2007 - 2012

Author:
Andre Schmidt, Robert Virkus

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Method Summary
static void hideSoftKeyboard()
          Hides the softkeyboard if the device supports it.
static boolean isFallbackToNetworkLocationOnGpsDisabled()
          Deprecated.  
static boolean isGpsEnabled()
          Deprecated. Use LocationService.isGpsEnabled()
static boolean isLightSupported()
          Checks if backlight can be controlled by the application
static boolean isSoftKeyboardShown()
          Checks is a virtual keyboard is currently shown.
static boolean isVibrateSupported()
          Checks if vibration can be controlled by the application
static void lightOff()
          Turns the backlight off
static boolean lightOn()
          Turns the backlight on on a device until lightOff() is called
 void run()
           
static void setSuicideOnExit(boolean suicideOnExit)
           
static void shouldFallbackToNetworkLocationOnGpsDisabled(boolean setFallbackOnGpsDisabled)
          Deprecated.  
static void showSoftKeyboard()
          Shows the softkeyboard if the device supports it.
static boolean vibrate(int duration)
          Vibrates the device for the given duration
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

run

public void run()
Specified by:
run in interface Runnable
Overrides:
run in class Thread

lightOn

public static boolean lightOn()
Turns the backlight on on a device until lightOff() is called

Returns:
true when backlight is supported on this device.
See Also:
lightOff()

lightOff

public static void lightOff()
Turns the backlight off

See Also:
lightOn()

isLightSupported

public static boolean isLightSupported()
Checks if backlight can be controlled by the application

Returns:
true when the backlight can be controlled by the application
See Also:
lightOn(), lightOff()

vibrate

public static boolean vibrate(int duration)
Vibrates the device for the given duration

Parameters:
duration - the duration in milliseconds
Returns:
true when the vibration was activated successfully

isVibrateSupported

public static boolean isVibrateSupported()
Checks if vibration can be controlled by the application

Returns:
true when the vibration can be controlled by the application

showSoftKeyboard

public static void showSoftKeyboard()
Shows the softkeyboard if the device supports it. This method is only supported on the Android platform at the moment.

See Also:
hideSoftKeyboard(), isSoftKeyboardShown()

hideSoftKeyboard

public static void hideSoftKeyboard()
Hides the softkeyboard if the device supports it. This method is only supported on the Android platform at the moment.

See Also:
showSoftKeyboard(), isSoftKeyboardShown()

isSoftKeyboardShown

public static boolean isSoftKeyboardShown()
Checks is a virtual keyboard is currently shown.

Returns:
true when a virtual keyboard is supported and visible at the moment
See Also:
showSoftKeyboard(), hideSoftKeyboard()

setSuicideOnExit

public static void setSuicideOnExit(boolean suicideOnExit)

shouldFallbackToNetworkLocationOnGpsDisabled

public static void shouldFallbackToNetworkLocationOnGpsDisabled(boolean setFallbackOnGpsDisabled)
Deprecated. 

This method allows the caller to disable the fallback to the network location provider when the GPS location provider is not available. Normally the network location provider is used in case the GPS location provider goes offline for some reason. With this method you can turn of this fallback. This is useful if you want to be sure that you always have full acurracy for your location or non at all.

Parameters:
setFallbackOnGpsDisabled - true if you want to disable the fallback mechanism, false otherwise.

isFallbackToNetworkLocationOnGpsDisabled

public static boolean isFallbackToNetworkLocationOnGpsDisabled()
Deprecated. 

This methods tells the caller if the fallback mechanism for the GPS location provider is enabled. See shouldFallbackToNetworkLocationOnGpsDisabled(boolean) for details.

Returns:
true if the fallback is disabled, false if the fallback is enabled (the default).

isGpsEnabled

public static boolean isGpsEnabled()
Deprecated. Use LocationService.isGpsEnabled()

Returns:
true if GPS is enabled, false otherwise.