Created
March 27, 2015 21:25
-
-
Save vitovalov/65044b39f5267494ccdb to your computer and use it in GitHub Desktop.
Get elapsed time from the first time user launched the app using SharedPreferences and Joda-Time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
long lastLaunchedDateMillis = VITPreferencesUtils.getLongGeneric(PuzzleApp.getInstance(), "first_launch_date", -1); | |
DateTime current = new DateTime(); | |
DateTime lastLaunchedDate = new DateTime(lastLaunchedDateMillis); | |
if (lastLaunchedDateMillis != -1) { | |
int secsElapsed = Seconds.secondsBetween(lastLaunchedDate, current).getSeconds(); | |
Log.e("VI PRINT", "HomeActivity.onCreate " + "secsElapsed:" + secsElapsed); | |
} else { | |
VITPreferencesUtils.saveLongGeneric(PuzzleApp.getInstance(), "first_launch_date", current.getMillis()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment