de.enough.polish.location
Class FallbackLocationProvider

java.lang.Object
  extended by javax.microedition.location.LocationProvider
      extended by de.enough.polish.location.FallbackLocationProvider
All Implemented Interfaces:
javax.microedition.location.LocationListener

public class FallbackLocationProvider
extends javax.microedition.location.LocationProvider
implements javax.microedition.location.LocationListener

A location provider that uses different location providers, e.g. Network and GPS providers. Location updates will be retrieved by the best (first) provider.

Author:
Robert Virkus, Richard Nkrumah

Field Summary
 
Fields inherited from class javax.microedition.location.LocationProvider
AVAILABLE, OUT_OF_SERVICE, TEMPORARILY_UNAVAILABLE
 
Method Summary
 javax.microedition.location.LocationProvider getActiveLocationProvider()
           
static FallbackLocationProvider getInstance(javax.microedition.location.Criteria[] criteria)
          Retrieves an instance of the FallbackLocationProvier
 javax.microedition.location.Location getLocation(int timeoutInSeconds)
           
 int getNumberOfUniqueLocationProviders()
          Retrieves the number of unique location providers that are used within this FallbackLocationProvider
 int getState()
           
 void locationUpdated(javax.microedition.location.LocationProvider provider, javax.microedition.location.Location loc)
          LocationListener method - do not call.
 void providerStateChanged(javax.microedition.location.LocationProvider changedProvider, int state)
          LocationListener method - do not call.
 void reset()
           
 void setFallbackLocationListener(FallbackLocationListener fallbackLocationListener)
          Sets the listener that is informed when a criteria is enabled
 void setLocationListener(javax.microedition.location.LocationListener listener, int interval, int timeout, int maxAge)
           
 String toString()
           
 
Methods inherited from class javax.microedition.location.LocationProvider
addProximityListener, getInstance, getLastKnownLocation, removeProximityListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getInstance

public static FallbackLocationProvider getInstance(javax.microedition.location.Criteria[] criteria)
                                            throws javax.microedition.location.LocationException
Retrieves an instance of the FallbackLocationProvier

Parameters:
criteria - the criteria that are sorted from the most to the least important one (so the most important one is in criteria[0]).
Returns:
the FallbackLocationProvider instance
Throws:
javax.microedition.location.LocationException - if all location providers are currently out of service

setFallbackLocationListener

public void setFallbackLocationListener(FallbackLocationListener fallbackLocationListener)
Sets the listener that is informed when a criteria is enabled

Parameters:
fallbackLocationListener - the listener, use null to remove listener

getNumberOfUniqueLocationProviders

public int getNumberOfUniqueLocationProviders()
Retrieves the number of unique location providers that are used within this FallbackLocationProvider

Returns:
the number

getLocation

public javax.microedition.location.Location getLocation(int timeoutInSeconds)
                                                 throws javax.microedition.location.LocationException,
                                                        InterruptedException
Specified by:
getLocation in class javax.microedition.location.LocationProvider
Throws:
javax.microedition.location.LocationException
InterruptedException

getState

public int getState()
Specified by:
getState in class javax.microedition.location.LocationProvider

reset

public void reset()
Specified by:
reset in class javax.microedition.location.LocationProvider

setLocationListener

public void setLocationListener(javax.microedition.location.LocationListener listener,
                                int interval,
                                int timeout,
                                int maxAge)
Specified by:
setLocationListener in class javax.microedition.location.LocationProvider

locationUpdated

public void locationUpdated(javax.microedition.location.LocationProvider provider,
                            javax.microedition.location.Location loc)
LocationListener method - do not call.

Specified by:
locationUpdated in interface javax.microedition.location.LocationListener

providerStateChanged

public void providerStateChanged(javax.microedition.location.LocationProvider changedProvider,
                                 int state)
LocationListener method - do not call.

Specified by:
providerStateChanged in interface javax.microedition.location.LocationListener

toString

public String toString()
Overrides:
toString in class Object

getActiveLocationProvider

public javax.microedition.location.LocationProvider getActiveLocationProvider()