Class LocationSharing

java.lang.Object
com.arubanetworks.meridian.locationsharing.LocationSharing

public class LocationSharing extends Object
  • Constructor Details

    • LocationSharing

      public LocationSharing()
  • Method Details

    • initWithAppKey

      public static void initWithAppKey(EditorKey appKey)
      Call this method to initialize Location Sharing.
      Parameters:
      appKey - app key
      Throws:
      IllegalStateException - If the editor token is not set or initialization failed.
    • shared

      public static LocationSharing shared()
      Call this method to get a valid LocationSharing instance.<p>This object is the main API for Location Sharing</p>
      Returns:
      current instance
    • setCurrentUser

      public void setCurrentUser(User currentUser)
      Call this method to set the current logged in user
      Parameters:
      currentUser - new user
    • getCurrentUser

      public User getCurrentUser()
      Call this method to get the current logged in user
      Returns:
      currentUser
    • addListener

      public void addListener(LocationSharing.Listener listener)
      Set a listener if you want to know when Location Sharing starts / stops updating user locations
      Parameters:
      listener - new Location Sharing listener
    • removeListener

      public void removeListener(LocationSharing.Listener listener)
      Removes a listener
      Parameters:
      listener - Location Sharing listener to remove
    • getAppKey

      public EditorKey getAppKey()
      Gets the current App Key
      Returns:
      appKey - current application key
    • setAppKey

      public void setAppKey(EditorKey appKey)
      Sets the current App Key
      Parameters:
      appKey - application key to use
    • getMode

      public LocationSharing.Mode getMode()
      Gets the current Location Sharing mode (FOREGROUND or BACKGROUND).<p>FOREGROUND will update user&rsquo;s location more often BACKGROUND will try to save as much power as it can while still offer an accurate location</p>
      Returns:
      current mode
    • setMode

      public void setMode(LocationSharing.Mode mode)
      Location Sharing can run in two modes, FOREGROUND and BACKGROUND.<p>FOREGROUND will update user&rsquo;s location more often BACKGROUND will try to save as much power as it can while still offer an accurate location</p>
      Parameters:
      mode - mode to run in (FOREGROUND or BACKGROUND)
    • startPostingLocationUpdates

      public boolean startPostingLocationUpdates(@NonNull Context context)
      Start uploading user&rsquo;s location
      Parameters:
      context - application context
      Returns:
      true if posting location updates has started
    • onRegisterJobAgainEvent

      public void onRegisterJobAgainEvent(LocationSharing.RegisterJobAgainEvent event)
    • stopPostingLocationUpdates

      public void stopPostingLocationUpdates(@NonNull Context context)
      Stop uploading user&rsquo;s location
      Parameters:
      context - application context
    • isUploadingServiceRunning

      public boolean isUploadingServiceRunning()
      Checks if the upload location service is currently running
      Returns:
      true if running
    • getStopPendingIntent

      public PendingIntent getStopPendingIntent(@NonNull Context context)
      Creates a PendingIntent to stop uploading user&rsquo;s location.<p>Useful to use in notifications for example.</p>
      Parameters:
      context - application context
      Returns:
      pending intent
    • createUser

      public void createUser(User user, LocationSharing.Callback<User> callback)
      Creates a new location sharing user.
      Parameters:
      user - all user&rsquo;s data. Only required field is <code>fullName</code>
      callback - returns new user
    • updateUser

      public void updateUser(User user, LocationSharing.Callback<User> callback)
      Updates a new location sharing user.
      Parameters:
      user - user&rsquo;s data. Required fields: key, password and fullName
      callback - returns updated user
    • acceptInvite

      public void acceptInvite(String inviteKey, LocationSharing.Callback<Friend> callback)
      Accepts an invite, creating a friendship between the current user and the invite creator.<p/> An user must be logged in (see `setCurrentUser()`)
      Parameters:
      inviteKey - key of the invitation to be accepted
      callback - returns a Friend object with the new friend
    • createInvite

      public void createInvite(LocationSharing.Callback<Invite> callback)
      Creates a new invite<p/> An user must be logged in (see `setCurrentUser()`)
      Parameters:
      callback - returns new invite
    • deleteProfile

      public void deleteProfile(@NonNull Context context, LocationSharing.Callback<Void> callback)
      Deletes current user&rsquo;s profile
      Parameters:
      callback - this method will call <code>onSuccess</code> if the profile was removed or <code>onError</code> if an error has occurred
    • removeFriend

      public void removeFriend(String friendId, LocationSharing.Callback<Void> callback)
      Removes friendship between current user and provided friend id<p/> An user must be logged in (see `setCurrentUser()`)
      Parameters:
      friendId - friend id to be unfriended
      callback - 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<p/> An user must be logged in (see `setCurrentUser()`)
      Parameters:
      context - application context
      photoUri - URI of photo to upload
      callback - returns updated friend
    • removeUserPhoto

      public void removeUserPhoto(LocationSharing.Callback<User> callback)
      Removes profile pic for the current user<p/> An user must be logged in (see `setCurrentUser()`)
      Parameters:
      callback - returns updated friend
    • getFriends

      public void getFriends(LocationSharing.Callback<List<Friend>> callback)
      Retrieves list of friends for the current user<p/> An user must be logged in (see `setCurrentUser()`)
      Parameters:
      callback - returns list of friends
    • getInvites

      public void getInvites(LocationSharing.Callback<List<Invite>> callback)
      Retrieves all invites created by the current user<p/> An user must be logged in (see `setCurrentUser()`)
      Parameters:
      callback - returns list of invites
    • revokeAllInvites

      public void revokeAllInvites(LocationSharing.Callback<Void> callback)
      Revokes all invites create by the current user<p/> 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.<p>The location is not sent if there are no friends to receive it</p>
      Returns:
      true if location is NOT being uploaded