Geocaching Game Plugin
A simple plugin that provides geolocation data to a Unity game, even when the screen is off
com.deovolentegames.geocachingunityplugin.GeocachingGameService Class Reference
Inheritance diagram for com.deovolentegames.geocachingunityplugin.GeocachingGameService:

Classes

class  LocalBinder
 Custom binder so that methods can be called on this Service. More...
 

Public Member Functions

void onCreate ()
 
void onDestroy ()
 
IBinder onBind (Intent intent)
 
void onConnected (@Nullable Bundle bundle)
 
void onConnectionSuspended (int i)
 
void onConnectionFailed (@NonNull ConnectionResult connectionResult)
 
void onLocationChanged (Location location)
 
void registerListener (GeocachingGamePlugin.LocationPluginListener listener)
 This method allows other classes to register listeners to this service that get called when the location is updated. More...
 
void deregisterListener (GeocachingGamePlugin.LocationPluginListener listener)
 This method allows other classes to unregister their registered listeners. More...
 
void activateReporting (boolean isActive)
 This method activates or deactivates reporting data to listeners. More...
 

Static Public Attributes

static final String TAG = GeocachingGameService.class.getSimpleName()
 
static int locationInterval = 5000
 
static int locationFastestInterval = 1000
 
static float locationAccuracy = 20
 
static float minSpeed = 0.1f
 
static float maxSpeed = 5f
 

Detailed Description

Geocaching Game Service

The GeocachingGameService is a background service that receives location data from the Google Location Service and sends the latitude, longitude and distance travelled to listeners.

It is designed to be used primarily with Unity to solve the problem in geocaching games where distance travelled while the phone's screen is off or the app is otherwise not in the foreground doesn't count.

GeocachingGamePlugin is the actual entry point for the Unity application so it can send information to this service.

Finally, here's the references that I used to create this code (mostly here for my own sake):

Author
Rory
Version
1.0
Since
2017-01-21
See also
GeocachingGamePlugin
deovolente.games

Member Function Documentation

◆ activateReporting()

void com.deovolentegames.geocachingunityplugin.GeocachingGameService.activateReporting ( boolean  isActive)

This method activates or deactivates reporting data to listeners.

Parameters
isActiveActivates reporting to listeners when true, deactivates when false.

◆ deregisterListener()

void com.deovolentegames.geocachingunityplugin.GeocachingGameService.deregisterListener ( GeocachingGamePlugin.LocationPluginListener  listener)

This method allows other classes to unregister their registered listeners.

Parameters
listenerThis is the listener to remove.

◆ onBind()

IBinder com.deovolentegames.geocachingunityplugin.GeocachingGameService.onBind ( Intent  intent)

◆ onConnected()

void com.deovolentegames.geocachingunityplugin.GeocachingGameService.onConnected ( @Nullable Bundle  bundle)

◆ onConnectionFailed()

void com.deovolentegames.geocachingunityplugin.GeocachingGameService.onConnectionFailed ( @NonNull ConnectionResult  connectionResult)

◆ onConnectionSuspended()

void com.deovolentegames.geocachingunityplugin.GeocachingGameService.onConnectionSuspended ( int  i)

◆ onCreate()

void com.deovolentegames.geocachingunityplugin.GeocachingGameService.onCreate ( )

◆ onDestroy()

void com.deovolentegames.geocachingunityplugin.GeocachingGameService.onDestroy ( )

◆ onLocationChanged()

void com.deovolentegames.geocachingunityplugin.GeocachingGameService.onLocationChanged ( Location  location)

◆ registerListener()

void com.deovolentegames.geocachingunityplugin.GeocachingGameService.registerListener ( GeocachingGamePlugin.LocationPluginListener  listener)

This method allows other classes to register listeners to this service that get called when the location is updated.

Parameters
listenerThis is the listener to add.

Member Data Documentation

◆ locationAccuracy

float com.deovolentegames.geocachingunityplugin.GeocachingGameService.locationAccuracy = 20
static

◆ locationFastestInterval

int com.deovolentegames.geocachingunityplugin.GeocachingGameService.locationFastestInterval = 1000
static

◆ locationInterval

int com.deovolentegames.geocachingunityplugin.GeocachingGameService.locationInterval = 5000
static

◆ maxSpeed

float com.deovolentegames.geocachingunityplugin.GeocachingGameService.maxSpeed = 5f
static

◆ minSpeed

float com.deovolentegames.geocachingunityplugin.GeocachingGameService.minSpeed = 0.1f
static

◆ TAG

final String com.deovolentegames.geocachingunityplugin.GeocachingGameService.TAG = GeocachingGameService.class.getSimpleName()
static

The documentation for this class was generated from the following file: