1

I am creating an application which will give me currently running task , it is working perfectly bellow 5.1 Lollipop

this is my code for bellow 5.1

mPackageName = ActivityManager.getRunningTasks(1).get(0).topActivity.getPackageName();

(I want only single application which is currently running)

but in 5.1 it is not giving me the right package

this code is running every 1 second. Please give me some suggestions

Thanks Amit

Amit Sharma
  • 926
  • 2
  • 10
  • 35
  • This hack was broken in 5.0. There's a new hack that works on 5.0 and 5.1, but it's broken on 6.0. – Kevin Krumwiede Oct 01 '15 at 15:32
  • I need this in 5.0 do you have any solution for this ? – Amit Sharma Oct 01 '15 at 15:33
  • Actually it was working perfectly in android 5.0 but i have update my phone i struck in this problem – Amit Sharma Oct 01 '15 at 15:34
  • Search this site for Usage Stats API. That will work on 6.0, but only on some devices because some manufacturers removed the activity to grant the required permission. – Kevin Krumwiede Oct 01 '15 at 15:35
  • I have also enable the App Usage Access – Amit Sharma Oct 01 '15 at 15:36
  • This app is like app lock , as you said some manufactrur are removed access , then how app lock is working , I have got some idea form that . But at the end i fail :( – Amit Sharma Oct 01 '15 at 15:38
  • 1
    IIRC, [this hack](http://stackoverflow.com/questions/30619349/android-5-1-1-and-above-getrunningappprocesses-returns-my-application-packag?lq=1) worked on 5.1 but apparently not 5.1.1. Going forward, app locks will not work unless they can access the Usage Stats API. – Kevin Krumwiede Oct 01 '15 at 15:44
  • Thanks , Kevin It is working perfectly, Hats off to you sir for great suggestion . Can You add this as answer so i can up-vote and It iwill be help full for others Thanks again – Amit Sharma Oct 01 '15 at 15:53

0 Answers0