Track particular user in android?
  • Hi,
    I have registered my application with Geoloqi and got Client ID,Client Secret.
    Using those I have created user_anon with phone number as user name and got display_name,user_id, access_token etc,
    then how can I track particular user in android.
  • 11 Comments sorted by
  • If you start up the LQService provided by the Android SDK it will automatically begin tracking the user in the Adaptive profile. If the device has an active network connection it will begin delivering location updates to the Geoloqi servers. You can query for those updates using the Geoloqi REST API.
  • You can use the `location/last` API endpoint to get the user's last location update. All you need to provide is that user's id. Simply sign the request with your application access token. This works because the application created that user.

    You may also be interested in the `location/history` endpoint. This works exactly the same way as above but returns a paginated list of all the user's location updates.
  • Was the user you are trying to access created by the same application token? Can you post the code you're using to make this request? Thanks!
  • You cannot use the API console to access this user's data. This is because the user was created by your application, not your developer account. You'll need to make a request to the Geoloqi API using your application credentials. You can do this using "curl" or one of our other client library projects (Python, Ruby, etc). Just make sure you use the same app credentials as you used with the Android SDK.
  • Hi twaddington,

    Thank you for your reply. Yes as you told I am using API console to retrieve the
    data. I am able to see list of users registered, By using users/list but how can
    get particular user lat & long. Can you please help me in this. Please let me
    know which API i have to use in this case. And the users are created as anonymous.
    users, doesn't have password. 
  • Hello twaddington,
    I am facing the same issue I don't know is it correct procedure or not. I have tried as you told. I have given appliation_access_token and user_id as keys, supplied corresponding values also to location/list in the API Consolve and I got ,
    "error_code": 403,
    "error": "forbidden",
    "error_description": "Access denied to this resource."

    Is there anything wrong from my end?
  • Hi twaddington,

    I am not at all using application access token.
    I just used Geoloqi sdk, and before starting the service I just used
    LQSharedPreferences.setClientId() and 
    LQSharedPreferences.setClientSecret() methods and the user is created by Geoloqi sdk itself.
    I am able to get the userId using session. I am able to get last recorded observation in android,
    but in the API console of Geoloqi I have used location/last with userid and application accesstoke as parameters but saying that
    "error_code": 403,
    "error": "forbidden",
    "error_description": "Access denied to this resource."
    Can you please help me how to trace particular user through API Console of Geoloqi.

  • Hi Twaddington,
    Thank you for your reply.
    Now I am able to find out user, using client library project.
    And I have one more problem.
    I am not able to catch,
       Failed to create anonymous user! No active network connection!
    Geoloqi sdk throws and catches this exception.
    I have to catch this exception, please let me know how it is possible?.
    Thank you very much for your support.

  • Hi twaddington,

    I am also doing same thing.
    When My mobile gps ON and wifi OFF, at this time if I sent request to Geoloqi
    it is saying that
    No active network connection!.
    Can you please help me in it.

    Thank you very much.
  • The Geoloqi Android SDK requires an active network connection to initialize itself. Once a valid session has been created, it can continue functioning even if the network connection drops.

    Unfortunately, there isn't a good way to catch the exception that is thrown when the session fails to initialize the anonymous user account. Since this work is being done autonomously by the service, it's difficult to access directly from your Activity code.

    You can check the state of the user session in several ways. Either by binding to the service and querying the getter methods of the tracker session; or by querying the static LQSharedPreferences getter methods, such as `getSessionAccessToken`. If there is no access token, then the service has failed to create an anonymous user account. I'd suggest checking the network state before you start the LQService class and alerting your user if there is not an active connection.

    We're working on making this initialization process smoother and may do something in the future to allow you to bind a callback to the service initialization process so you know when it's finished.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion