Class LocationSharing
java.lang.Object
com.arubanetworks.meridian.locationsharing.LocationSharing
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Callback interface for Location Sharing operationsstatic interface
static enum
protected static class
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
acceptInvite
(String inviteKey, LocationSharing.Callback<Friend> callback) Accepts an invite, creating a friendship between the current user and the invite creator.void
addListener
(LocationSharing.Listener listener) Set a listener if you want to know when Location Sharing starts / stops updating user locationsvoid
createInvite
(LocationSharing.Callback<Invite> callback) Creates a new invitevoid
createUser
(User user, LocationSharing.Callback<User> callback) Creates a new location sharing user.void
deleteProfile
(Context context, LocationSharing.Callback<Void> callback) Deletes current user’s profileGets the current App KeyCall this method to get the current logged in uservoid
getFriends
(LocationSharing.Callback<List<Friend>> callback) Retrieves list of friends for the current uservoid
getInvites
(LocationSharing.Callback<List<Invite>> callback) Retrieves all invites created by the current usergetMode()
Gets the current Location Sharing mode (FOREGROUND or BACKGROUND).getStopPendingIntent
(Context context) Creates a PendingIntent to stop uploading user’s location.static void
initWithAppKey
(EditorKey appKey) Call this method to initialize Location Sharing.boolean
Checks if the location is currently being sent to server.boolean
Checks if the upload location service is currently runningvoid
void
removeFriend
(String friendId, LocationSharing.Callback<Void> callback) Removes friendship between current user and provided friend idvoid
removeListener
(LocationSharing.Listener listener) Removes a listenervoid
removeUserPhoto
(LocationSharing.Callback<User> callback) Removes profile pic for the current uservoid
revokeAllInvites
(LocationSharing.Callback<Void> callback) Revokes all invites create by the current uservoid
Sets the current App Keyvoid
setCurrentUser
(User currentUser) Call this method to set the current logged in uservoid
setMode
(LocationSharing.Mode mode) Location Sharing can run in two modes, FOREGROUND and BACKGROUND.static LocationSharing
shared()
Call this method to get a valid LocationSharing instance.boolean
startPostingLocationUpdates
(Context context) Start uploading user’s locationvoid
stopPostingLocationUpdates
(Context context) Stop uploading user’s locationvoid
updateUser
(User user, LocationSharing.Callback<User> callback) Updates a new location sharing user.void
uploadUserPhoto
(Context context, Uri photoUri, LocationSharing.Callback<User> callback) Uploads a photo for the current user
-
Constructor Details
-
LocationSharing
public LocationSharing()
-
-
Method Details
-
initWithAppKey
Call this method to initialize Location Sharing.- Parameters:
appKey
- app key- Throws:
IllegalStateException
- If the editor token is not set or initialization failed.
-
setCurrentUser
Call this method to set the current logged in user- Parameters:
currentUser
- new user
-
getCurrentUser
Call this method to get the current logged in user- Returns:
- currentUser
-
addListener
Set a listener if you want to know when Location Sharing starts / stops updating user locations- Parameters:
listener
- new Location Sharing listener
-
removeListener
Removes a listener- Parameters:
listener
- Location Sharing listener to remove
-
getAppKey
Gets the current App Key- Returns:
- appKey - current application key
-
setAppKey
Sets the current App Key- Parameters:
appKey
- application key to use
-
getMode
Gets the current Location Sharing mode (FOREGROUND or BACKGROUND).FOREGROUND will update user’s location more often BACKGROUND will try to save as much power as it can while still offer an accurate location
- Returns:
- current mode
-
setMode
Location Sharing can run in two modes, FOREGROUND and BACKGROUND.FOREGROUND will update user’s location more often BACKGROUND will try to save as much power as it can while still offer an accurate location
- Parameters:
mode
- mode to run in (FOREGROUND or BACKGROUND)
-
startPostingLocationUpdates
Start uploading user’s location- Parameters:
context
- application context- Returns:
- true if posting location updates has started
-
onRegisterJobAgainEvent
-
stopPostingLocationUpdates
Stop uploading user’s location- Parameters:
context
- application context
-
isUploadingServiceRunning
public boolean isUploadingServiceRunning()Checks if the upload location service is currently running- Returns:
- true if running
-
getStopPendingIntent
Creates a PendingIntent to stop uploading user’s location.Useful to use in notifications for example.
- Parameters:
context
- application context- Returns:
- pending intent
-
createUser
Creates a new location sharing user.- Parameters:
user
- all user’s data. Only required field isfullName
callback
- returns new user
-
updateUser
Updates a new location sharing user.- Parameters:
user
- user’s data. Required fields: key, password and fullNamecallback
- returns updated user
-
acceptInvite
Accepts an invite, creating a friendship between the current user and the invite creator. An user must be logged in (see `setCurrentUser()`)- Parameters:
inviteKey
- key of the invitation to be acceptedcallback
- returns a Friend object with the new friend
-
createInvite
Creates a new invite An user must be logged in (see `setCurrentUser()`)- Parameters:
callback
- returns new invite
-
deleteProfile
Deletes current user’s profile- Parameters:
callback
- this method will callonSuccess
if the profile was removed oronError
if an error has occurred
-
removeFriend
Removes friendship between current user and provided friend id An user must be logged in (see `setCurrentUser()`)- Parameters:
friendId
- friend id to be unfriendedcallback
- onSuccess called if friend removed
-
uploadUserPhoto
public void uploadUserPhoto(@NonNull Context context, Uri photoUri, LocationSharing.Callback<User> callback) Uploads a photo for the current user An user must be logged in (see `setCurrentUser()`)- Parameters:
context
- application contextphotoUri
- URI of photo to uploadcallback
- returns updated friend
-
removeUserPhoto
Removes profile pic for the current user An user must be logged in (see `setCurrentUser()`)- Parameters:
callback
- returns updated friend
-
getFriends
Retrieves list of friends for the current user An user must be logged in (see `setCurrentUser()`)- Parameters:
callback
- returns list of friends
-
getInvites
Retrieves all invites created by the current user An user must be logged in (see `setCurrentUser()`)- Parameters:
callback
- returns list of invites
-
revokeAllInvites
Revokes all invites create by the current user An user must be logged in (see `setCurrentUser()`)- Parameters:
callback
- returns onSuccess if the revoke succeeded
-
isUploadingPaused
public boolean isUploadingPaused()Checks if the location is currently being sent to server.The location is not sent if there are no friends to receive it
- Returns:
- true if location is NOT being uploaded
-