I am new in Android and is developing an app which runs in background as service to collect user activity. till now my app is able to get information about Time_Start, Time_End and Name of other app used by user.
I want to improve my app to be able to count how many interactions(like user tap, touch,...) user make while using other app. Can any one give some advices about this issue? Just the way to do and I'll do all details by myself.
Thanks!
The best way to do this is to implement Listeners for the types of user interactions you would like to count. Have a global variable in your activity. Every time the user interacts, add one to it.
If you want to keep count across the entire app, you could save a variable in SharedPreferences, and at the end of each activity, add your activity's global variable count to the value you have store in shared preferences. Or, you could just edit the value you have stored in SharedPreferences right off the bat on every user interaction. Just remember to reset the value of the SharedPreferences when you first start the application, as values stored in SharedPreferences are stored even after the app is closed unless you specifically remove them, or clear the SharedPreferences.
Another way you could keep count is by using a global static variable that is accessible from all other activities. This way you would be able to increment it from other activities. This is generally considered bad practices though, so I advise against this.
The documentation for SharedPreferences is here:
http://developer.android.com/reference/android/content/SharedPreferences.html
The documentation for implementing input event Listeners is here:
http://developer.android.com/guide/topics/ui/ui-events.html
Hope this helped!