Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

LifeLog Android Library

This is an Android (not pure java) wrapper for the LifeLog Web API.

Book session on Codementor

Release Codacy Badge

How to add to your project

Add it using jitpack maven distribution.
Add the jitpack maven repository

    repositories {
        maven {
            url ""

Add the dependency

    dependencies {
	        compile 'in.championswimmer:Lifelog-Android-Library:1.+'

###Initialise In your Application class, inside the onCreate body, add this

LifeLog.initialise("clientid", "secret", "");

Replace clientid, secret and callbackurl with your respective values of the app that you have registered on LifeLog.

###Login and authentication ####Login To log the user in for the first time, use this simple static method


Note that, after login is completed, we will return back to same activity. Internally, doLogin makes a startActivityForResult call with LifeLog.LOGINACTIVITY_REQUEST_CODE as request code. Handle the returning user like this

    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == LifeLog.LOGINACTIVITY_REQUEST_CODE) {
            if (resultCode == RESULT_OK) {
                Toast.makeText(this, "User authenticated", Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(this, "User authentication failed", Toast.LENGTH_SHORT).show();
        } else {
            super.onActivityResult(requestCode, resultCode, data);

Checking Authentication state

You would want to check if the user is authenticated or not. Even if he is, we may need to refresh the auth token. Again, simple code for that.

LifeLog.checkAuthentication(this, new LifeLog.OnAuthenticationChecked() {
    public void onAuthChecked(boolean authenticated) {
        if (authenticated) {
            //User is authenticated, we can do API requests now
        } else {
            //User is not authenticated. Make him login (or whatever suits your app's flow)

API Requests

me Endpoint

Create an object of MeRequest using the static MeRequest.prepareRequest method.

The data gets actually fetched when you call get()

MeRequest meRequest = MeRequest.prepareRequest();
                    meRequest.get(MainActivity.this, new MeRequest.OnMeFetched() {
                        public void onMeFetched(Me meData) {
                            Log.d(TAG, "onMeFetched: " + meData.getUsername());

locations endpoint

Create an object of MeLocationRequest using one of the two prepareRequest methods. One allows you to specify start and end time. Other doesn't. You can set either of start or end time to be null as well.

The data fetching actually starts when get is called. After the data is fetched, the onLocationFetched callback is hit. A List<> of MeLocation objects are at your disposal.

MeLocationRequest llLocation = MeLocationRequest.prepareRequest(500);
    llLocation.get(MainActivity.this, new MeLocationRequest.OnLocationFetched() {
        public void onLocationFetched(ArrayList<MeLocation> locations) {
            for (MeLocation loc : locations) {
                String id = loc.getId();
                Calendar startTime = loc.getStartTime();
                //continue likewise



An Android Library/API to access Sony Lifelog palatform.







No packages published