public class LocationSharing
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
LocationSharing.Callback<T>
Callback interface for Location Sharing operations
|
static interface |
LocationSharing.Listener |
static class |
LocationSharing.Mode |
protected static class |
LocationSharing.RegisterJobAgainEvent |
Constructor and Description |
---|
LocationSharing() |
Modifier and Type | Method and Description |
---|---|
void |
acceptInvite(java.lang.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 locations
|
void |
createInvite(LocationSharing.Callback<Invite> callback)
Creates a new invite An user must be logged in (see
setCurrentUser() ) |
void |
createUser(User user,
LocationSharing.Callback<User> callback)
Creates a new location sharing user.
|
void |
deleteProfile(android.content.Context context,
LocationSharing.Callback<java.lang.Void> callback)
Deletes current user’s profile
|
EditorKey |
getAppKey()
Gets the current App Key
|
User |
getCurrentUser()
Call this method to get the current logged in user
|
void |
getFriends(LocationSharing.Callback<java.util.List<Friend>> callback)
Retrieves list of friends for the current user An user must be logged in (see
setCurrentUser() ) |
void |
getInvites(LocationSharing.Callback<java.util.List<Invite>> callback)
Retrieves all invites created by the current user An user must be logged in (see
setCurrentUser() ) |
LocationSharing.Mode |
getMode()
Gets the current Location Sharing mode (FOREGROUND or BACKGROUND).
|
android.app.PendingIntent |
getStopPendingIntent(android.content.Context context)
Creates a PendingIntent to stop uploading user’s location.
|
static void |
initWithAppKey(EditorKey appKey)
Call this method to initialize Location Sharing.
|
boolean |
isUploadingServiceRunning()
Checks if the upload location service is currently running
|
void |
onRegisterJobAgainEvent(LocationSharing.RegisterJobAgainEvent event) |
void |
removeFriend(java.lang.String friendId,
LocationSharing.Callback<java.lang.Void> callback)
Removes friendship between current user and provided friend id An user must be logged in (see
setCurrentUser() ) |
void |
removeListener(LocationSharing.Listener listener)
Removes a listener
|
void |
removeUserPhoto(LocationSharing.Callback<User> callback)
Removes profile pic for the current user An user must be logged in (see
setCurrentUser() ) |
void |
revokeAllInvites(LocationSharing.Callback<java.lang.Void> callback)
Revokes all invites create by the current user An user must be logged in (see
setCurrentUser() ) |
void |
setAppKey(EditorKey appKey)
Sets the current App Key
|
void |
setCurrentUser(User currentUser)
Call this method to set the current logged in user
|
void |
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(android.content.Context context)
Start uploading user’s location
|
void |
stopPostingLocationUpdates(android.content.Context context)
Stop uploading user’s location
|
void |
updateUser(User user,
LocationSharing.Callback<User> callback)
Updates a new location sharing user.
|
void |
uploadUserPhoto(android.content.Context context,
android.net.Uri photoUri,
LocationSharing.Callback<User> callback)
Uploads a photo for the current user An user must be logged in (see
setCurrentUser() ) |
public static void initWithAppKey(EditorKey appKey)
Call this method to initialize Location Sharing.
appKey
- app keyjava.lang.IllegalStateException
- If the editor token is not set or initialization failed.public static LocationSharing shared()
Call this method to get a valid LocationSharing instance. This object is the main API for Location Sharing
public void setCurrentUser(User currentUser)
Call this method to set the current logged in user
currentUser
- new userpublic User getCurrentUser()
Call this method to get the current logged in user
public void addListener(LocationSharing.Listener listener)
Set a listener if you want to know when Location Sharing starts / stops updating user locations
listener
- new Location Sharing listenerpublic void removeListener(LocationSharing.Listener listener)
Removes a listener
listener
- Location Sharing listener to removepublic EditorKey getAppKey()
Gets the current App Key
public void setAppKey(EditorKey appKey)
Sets the current App Key
appKey
- application key to usepublic LocationSharing.Mode 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
public void setMode(LocationSharing.Mode mode)
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
mode
- mode to run in (FOREGROUND or BACKGROUND)public boolean startPostingLocationUpdates(@NonNull android.content.Context context)
Start uploading user’s location
context
- application contextpublic void onRegisterJobAgainEvent(LocationSharing.RegisterJobAgainEvent event)
public void stopPostingLocationUpdates(@NonNull android.content.Context context)
Stop uploading user’s location
context
- application contextpublic boolean isUploadingServiceRunning()
Checks if the upload location service is currently running
public android.app.PendingIntent getStopPendingIntent(@NonNull android.content.Context context)
Creates a PendingIntent to stop uploading user’s location. Useful to use in notifications for example.
context
- application contextpublic void createUser(User user, LocationSharing.Callback<User> callback)
Creates a new location sharing user.
user
- all user’s data. Only required field is fullName
callback
- returns new userpublic void updateUser(User user, LocationSharing.Callback<User> callback)
Updates a new location sharing user.
user
- user’s data. Required fields: key, password and fullNamecallback
- returns updated userpublic void acceptInvite(java.lang.String inviteKey, LocationSharing.Callback<Friend> callback)
Accepts an invite, creating a friendship between the current user and the invite creator.
An user must be logged in (seesetCurrentUser()
)inviteKey
- key of the invitation to be acceptedcallback
- returns a Friend object with the new friendpublic void createInvite(LocationSharing.Callback<Invite> callback)
Creates a new invite
An user must be logged in (seesetCurrentUser()
)callback
- returns new invitepublic void deleteProfile(@NonNull android.content.Context context, LocationSharing.Callback<java.lang.Void> callback)
Deletes current user’s profile
callback
- this method will call onSuccess
if the profile was removed or onError
if an error has occurredpublic void removeFriend(java.lang.String friendId, LocationSharing.Callback<java.lang.Void> callback)
Removes friendship between current user and provided friend id
An user must be logged in (seesetCurrentUser()
)friendId
- friend id to be unfriendedcallback
- onSuccess called if friend removedpublic void uploadUserPhoto(@NonNull android.content.Context context, android.net.Uri photoUri, LocationSharing.Callback<User> callback)
Uploads a photo for the current user
An user must be logged in (seesetCurrentUser()
)context
- application contextphotoUri
- URI of photo to uploadcallback
- returns updated friendpublic void removeUserPhoto(LocationSharing.Callback<User> callback)
Removes profile pic for the current user
An user must be logged in (seesetCurrentUser()
)callback
- returns updated friendpublic void getFriends(LocationSharing.Callback<java.util.List<Friend>> callback)
Retrieves list of friends for the current user
An user must be logged in (seesetCurrentUser()
)callback
- returns list of friendspublic void getInvites(LocationSharing.Callback<java.util.List<Invite>> callback)
Retrieves all invites created by the current user
An user must be logged in (seesetCurrentUser()
)callback
- returns list of invitespublic void revokeAllInvites(LocationSharing.Callback<java.lang.Void> callback)
Revokes all invites create by the current user
An user must be logged in (seesetCurrentUser()
)callback
- returns onSuccess if the revoke succeeded