Page 1 of 2

App usage time tracker

Posted: 18 May 2016 08:39
by vamzicool
Since I wanted to know how much time I spent on any app one my phone I created these two flows and on widget. "App task started" flow logs the time the app was launched. "App task ended" flow logs the time the respective app was dismissed. It also calculates the duration the app was used. The app usage widget is used to display the top ten used apps. It has clickable actions . Top most portion of the widget when clicked resets the app usage data. Bottom portion when clicked display the current app usage times. Please note that the duration of app usage is not calculated if the app is running in the background. Here are the flows and widget :

http://automagic4android.com/flow.php?i ... a8132da742

Re: App usage time tracker

Posted: 26 May 2016 07:13
by vamzicool
Updated flows which includes top 15 apps that is used the most. Widget image attached here.

http://automagic4android.com/flow.php?i ... f00d59ff6f

Aside : Since I have a list of excluded apps , my script logic loops through the top 15 apps and also removes the excluded apps which results in the widget showing less than 15 apps. In scripting, wish there was removeMapEntries function to remove all the other apps other than the top 15 so that I didnt have to loop through apps. removeMapEntry doesn't seem to work.

Re: App usage time tracker

Posted: 26 May 2016 09:12
by Bushmills
Have you considered using Gleeo or another time/event tracker to do the actual calculation - and possibly visualisation -, and let the flow simply start/stop activity recording?

Re: App usage time tracker

Posted: 26 May 2016 13:15
by vamzicool
@Bushmills thank you for your suggestion. I tried gleeo with automagic but sadly it doesn't record app usage intervals in seconds.

Re: App usage time tracker

Posted: 27 May 2016 20:16
by Claas
What exactly do i have to do after activating the flows and placing the widget?

...did it and it keeps showing me whats on the screenshot - i feel dumb =)

Re: App usage time tracker

Posted: 28 May 2016 09:06
by vamzicool
@Claas the widget has two clickable actions, top and bottom click. if you click the top portion of the widget, it resets the app usage data. If you click the bottom portion of the widget, it refreshes and shows the latest app usage data. For the widget to show any new data, you have to click the bottom portion anytime you need the latest app usage data. I hope this helps....

Note : After clicking the top portion, click the bottom portion only after using some apps as this widget needs some app usage data to be displayed. Otherwise you may get error message.

Re: App usage time tracker

Posted: 28 May 2016 21:17
by Claas
When I click on top nothing happens and bottom always brings up an error message

Log files are too much for me =)

28.05.2016 23:16:10.005 [Clickable WidgetApp usage] Start executing action 'Script: Show app usage'
28.05.2016 23:16:10.032 [Clickable WidgetApp usage] Action 'Script: Show app usage'
ch.gridvision.ppam.androidautomagic.simplelang.a.d: Error while calling function getElement (Expression: getElement(apps, i)[line 11], Cause: Invalid index 0, size is 0)
at ch.gridvision.ppam.androidautomagic.simplelang.a.b.a(SourceFile:736)
at ch.gridvision.ppam.androidautomagic.simplelang.c.ah.b(SourceFile:49)
at ch.gridvision.ppam.androidautomagic.simplelang.c.b.a(SourceFile:40)
at ch.gridvision.ppam.androidautomagic.simplelang.a.b.a(SourceFile:109)
at ch.gridvision.ppam.androidautomagic.simplelang.c.w.b(SourceFile:25)
at ch.gridvision.ppam.androidautomagic.simplelang.a.b.a(SourceFile:396)
at ch.gridvision.ppam.androidautomagic.simplelang.c.d.b(SourceFile:22)
at ch.gridvision.ppam.androidautomagic.simplelang.c.b.a(SourceFile:40)
at ch.gridvision.ppam.androidautomagic.simplelang.a.b.a(SourceFile:109)
at ch.gridvision.ppam.androidautomagic.simplelang.c.w.b(SourceFile:25)
at ch.gridvision.ppam.androidautomagic.simplelang.a.b.a(SourceFile:803)
at ch.gridvision.ppam.androidautomagic.simplelang.c.y.b(SourceFile:42)
at ch.gridvision.ppam.androidautomagic.simplelang.c.b.a(SourceFile:40)
at ch.gridvision.ppam.androidautomagic.simplelang.a.b.a(SourceFile:144)
at ch.gridvision.ppam.androidautomagic.simplelang.c.ac.b(SourceFile:23)
at ch.gridvision.ppam.androidautomagic.simplelang.c.b.a(SourceFile:40)
at ch.gridvision.ppam.androidautomagic.simplelang.a.b.a(SourceFile:109)
at ch.gridvision.ppam.androidautomagic.simplelang.c.w.b(SourceFile:25)
at ch.gridvision.ppam.androidautomagic.simplelang.a.b.a(SourceFile:886)
at ch.gridvision.ppam.androidautomagic.simplelang.c.ab.b(SourceFile:78)
at ch.gridvision.ppam.androidautomagic.simplelang.c.b.a(SourceFile:40)
at ch.gridvision.ppam.androidautomagic.simplelang.a.b.a(SourceFile:109)
at ch.gridvision.ppam.androidautomagic.simplelang.c.w.b(SourceFile:25)
at ch.gridvision.ppam.androidautomagic.simplelang.a.b.a(SourceFile:803)
at ch.gridvision.ppam.androidautomagic.simplelang.c.y.b(SourceFile:42)
at ch.gridvision.ppam.androidautomagic.simplelang.c.b.a(SourceFile:40)
at ch.gridvision.ppam.androidautomagic.simplelang.a.b.a(SourceFile:116)
at ch.gridvision.ppam.androidautomagic.simplelang.c.am.b(SourceFile:33)
at ch.gridvision.ppam.androidautomagic.simplelang.a.k.a(SourceFile:836)
at ch.gridvision.ppam.androidautomagic.simplelang.a.k.a(SourceFile:817)
at ch.gridvision.ppam.androidautomagic.c.a.et$1.d(SourceFile:119)
at ch.gridvision.ppam.androidautomagic.c.a.et$1.a(SourceFile:110)
at ch.gridvision.ppam.androidautomagiclib.util.dj$1.run(SourceFile:39)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
at java.util.ArrayList.get(ArrayList.java:308)
at ch.gridvision.ppam.androidautomagic.simplelang.a.c.a(SourceFile:1983)
at ch.gridvision.ppam.androidautomagic.simplelang.a.b.a(SourceFile:728)
... 33 more

Re: App usage time tracker

Posted: 29 May 2016 13:40
by vamzicool
Note : After clicking the top portion, click the bottom portion only after using some apps as this widget needs some app usage data to be displayed. Otherwise you may get error message.

Re: App usage time tracker

Posted: 29 May 2016 14:19
by MURTUMA
@vamzicool: You should propably replace the "Show app usage" script action with an actual flow, which contains the said script. That way you could properly handle the error message with exception line. I would show something like "not enough statistics gathered" in the widget when the exception occurs.

Re: App usage time tracker

Posted: 29 May 2016 15:09
by vamzicool
@MURTUMA thank you for your suggestion. That's a good way to handle that error.