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!

http://stackoverflow.com/questions/24590533/how-to-get-recent-tasks-on-android-l/26885469#26885469
]]>

7 Commentsto Hi..

  1. Anonymous says:

    < ![CDATA[

    Please share your script

    ]]>

  2. Anonymous says:

    < ![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 🙁

    ]]>

  3. Anonymous says:

    < ![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

    ]]>

  4. Anonymous says:

    < ![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

    ]]>

  5. Anonymous says:

    < ![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.

    ]]>

  6. Anonymous says:

    < ![CDATA[

    But maybe the list is just empty because you don’t have the permission.

    ]]>

  7. Anonymous says:

    < ![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!

    ]]>

Leave a Reply

Your email address will not be published. Required fields are marked *