Post your questions and help other users.
Moderator: Martin
-
Lucy
- Posts: 225
- Joined: 10 Aug 2019 11:24
Post
by Lucy » 25 Nov 2019 14:34
Hey i have this simple scriot that i use for call duration. I assumed with slight modifications it would serve the same purpose with apps running duration. However when i run it , it errors. The only modifications done are name changes. Other than that it is exact what i successfully use for call duration. What could i be doing wrong?
Code: Select all
// end app time
global_app_end_time = getDurationMillis(triggertime);
global_app_runtime = (global_app_end_time - global_app_start_time);
global_runtime_str = (getDurationString(global_app_runtime));
date = getDate();
testrun =
"{date,dateformat,EEEE dd. MMM yy hh:mm:ss a}";
global_app_end_time = testrun;
global_app_name = {app_name};
global_app_package = {package_name};
-
Desmanto
- Posts: 2709
- Joined: 21 Jul 2017 17:50
Post
by Desmanto » 25 Nov 2019 17:50
I don't understand the getDurationMillis(). Doesn't triggertime already in millis? You can simply use the
Code: Select all
global_app_end_time = triggertime;
Same with your start_time (not shown here how to get the value, but I assume it is triggertime too). Runtime calculation should be correct already. Need to know what error do you have, maybe it is unrelated to this calculation.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
-
Lucy
- Posts: 225
- Joined: 10 Aug 2019 11:24
Post
by Lucy » 25 Nov 2019 18:05
Lol thanks. Im always going about it the hard way. Bc the mills was in function menu i thought that was how i had to do it
... i will look on to it a lil more and if error persists i will copy the error to show you. In the log from memory i think it was unable to convert mills to string but i will keep the error next time if i dont fix it
-
Lucy
- Posts: 225
- Joined: 10 Aug 2019 11:24
Post
by Lucy » 25 Nov 2019 18:14
26.11.2019 05:08:32.018 [App Usage end] End executing action 'Script: // end app time global_app_end_time = triggertime; global_app_runtime = (global_app_end_time - global_app_start_time); global_runtime_str = (getDurationString(global_app_runtime)); date = getDate(); testrun = "{date,dateformat,EEEE dd. MMM yy hh:mm:ss a}"; global_app_end_time = testrun; global_app_name = {app_name}; global_app_package = {package_name};' and exception can not apply operation - to values '1574705311907' and 'Tuesday 26. Nov. 19 01:25:07 am' (Expression: global_app_end_time - global_app_start_time[line 5])
26.11.2019 05:08:32.389 [App Usage end] Flow ends execution due to errors
26.11.2019 05:08:32.389 [App Usage end] Error:
ch.gridvision.ppam.androidautomagic.simplelang.a.d: can not apply operation - to values '1574705311907' and 'Tuesday 26. Nov. 19 01:25:07 am' (Expression: global_app_end_time - global_app_start_time[line 5])
-
Desmanto
- Posts: 2709
- Joined: 21 Jul 2017 17:50
Post
by Desmanto » 25 Nov 2019 18:22
can not apply operation - to values '1574705311907' and 'Tuesday 26. Nov. 19 01:25:07 am'
Nah, exactly as I have guessed. Your global_app_start_time is in string type, not date type. You have converted it to string before storing it. That's why you can't do any calculation to it. It is always recommended to store all time/date type in its original type, so you can do calculation. Only when you need to show it to user interface, then you convert it to friendly dateformat.
You need to remove the part in your global_app_start_time which convert it to dateformat string type, and assign the triggertime directly to it.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
-
Lucy
- Posts: 225
- Joined: 10 Aug 2019 11:24
Post
by Lucy » 26 Nov 2019 04:00
Lol thanks hunny... I'll get to it
-
Lucy
- Posts: 225
- Joined: 10 Aug 2019 11:24
Post
by Lucy » 26 Nov 2019 12:59
Lol omgosh... i FINALLY got it working
With this i get:
App name
Package name
Time started (readable format)
Duration count (readable format)
The start script gives me the "app count", time start , app name and package name.
Code: Select all
global_app_end_time = triggertime;
global_app_runtime = (global_app_end_time - global_app_start_time);
global_app_name = {app_name};
global_app_package = {package_name};
global_app_runtime_format = getDurationString(global_app_runtime);
date = getDate();
global_app_end_date =
"{date,dateformat,EEEE, dd/MMM/yyyy, hh:mm:ss a}";
/code]
-
Desmanto
- Posts: 2709
- Joined: 21 Jul 2017 17:50
Post
by Desmanto » 26 Nov 2019 13:47
Nice to see it working.
Actually you don't have to put bracket on the variable assignment. But maybe that is your scripting style to identify glovar.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
-
Lucy
- Posts: 225
- Joined: 10 Aug 2019 11:24
Post
by Lucy » 27 Nov 2019 03:00
Thanks!!
Haha yeah i know... when i put it in my clipboard and pasted it on the script its how it came and i just left it☺