Hi..
Hi..
I’ve been trying to bindClass and use ‘UsageStatsManager’ in LL script without luck..
I’m trying to get a recent apps list like this…
http://stackoverflow.com/questions/24590533/how-to-get-recent-tasks-on-android-l/26885469#26885469
Is this possible? Or I’m thinking it wont work because of the permissions?
Thanks!
]]>« 1st picture Homescreen, 2nd picture Homescreen when charging (Previous Post)
< ![CDATA[
Please share your script
]]>
< ![CDATA[
I haven’t gotten very far, just..
—
LL.bindClass(“android.app.usage.UsageStatsManager”)
//Then I get into trouble..
var m = UsageStatsManager.getSystemService(“usagestats”);
//get this..
//has no public instance field or method named “getSystemService”
—
I don’t know much Java and not very skilled with LL scripts…
Was just wondering if it was because of the permissions you need with using ‘UsageStatsManager’
sorry 🙁
]]>
< ![CDATA[
http://developer.android.com/reference/android/app/usage/UsageStatsManager.html
There is no getSystemService in this class.
You probably have to use LL.getContext().getSystemService
]]>
< ![CDATA[
Thanx!
Now I don’t get any errors.. But I get an empty list…
LL.bindClass(“android.app.usage.UsageStatsManager”);
LL.bindClass(“android.app.usage.UsageStats”);
LL.bindClass(“java.util.Calendar”);
var m = LL.getContext().getSystemService(“usagestats”)
var time = Calendar.getInstance().getTimeInMillis();
var task = m.queryUsageStats(UsageStatsManager.INTERVAL_DAILY, time – 1000*60, time);
alert( task.size() );
//shows 0
]]>
< ![CDATA[
I would recommend to use queryandaggregateusagestats here. If you don’t want to do that: if you specify Interval_Daily, the time span should be at least a day.
]]>
< ![CDATA[
But maybe the list is just empty because you don’t have the permission.
]]>
< ![CDATA[
thanx for ‘queryandaggregateusagestats’ wow, long word 🙂
I still got 0 in size, so I think it’s because the permissions… 🙁
anyway, thanx for your help!
]]>