net.hockeyapp.android
Class Tracking

java.lang.Object
  extended by net.hockeyapp.android.Tracking

public class Tracking
extends java.lang.Object

Description

This class defines methods to track the app's usage time.

License

 Copyright (c) 2012 Codenauts UG
 
 Permission is hereby granted, free of charge, to any person
 obtaining a copy of this software and associated documentation
 files (the "Software"), to deal in the Software without
 restriction, including without limitation the rights to use,
 copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the
 Software is furnished to do so, subject to the following
 conditions:
 
 The above copyright notice and this permission notice shall be
 included in all copies or substantial portions of the Software.
 
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.
 

Author:
Thomas Dohmke

Constructor Summary
Tracking()
           
 
Method Summary
static long getUsageTime(Context context)
          Returns the usage time of the current version in seconds.
static void startUsage(Activity activity)
          Starts tracking of the usage time for the given activity.
static void stopUsage(Activity activity)
          Stops tracking of the usage time for the given activity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Tracking

public Tracking()
Method Detail

startUsage

public static void startUsage(Activity activity)
Starts tracking of the usage time for the given activity. The current time is saved in shared preferences with a unique key.

Parameters:
activity - Instance of activity

stopUsage

public static void stopUsage(Activity activity)
Stops tracking of the usage time for the given activity. Reads the start time which was stored by startUsage and calculates the difference. This difference is then added to the total usage time for the current version.

Parameters:
activity - Instance of activity

getUsageTime

public static long getUsageTime(Context context)
Returns the usage time of the current version in seconds.

Parameters:
context - Context to access shared preference.
Returns:
Usage time in seconds.