0

I am interested in writing an app to record how the resources on my phone are used by those installed apps. These resources can be microphone, camera, bluetooth, GPS, contacts, network, battery usage, sensors etc. I would like to record when and how long did a app used a resource.

Is there any API on android which I can use to access those information ?

Thanks in advance for your time and suggestions!

Foreverniu
  • 349
  • 1
  • 3
  • 18

1 Answers1

0

Use this code.ihope will help you

 PackageManager packageManager = this.getPackageManager();
                List<PackageInfo> applist = packageManager.getInstalledPackages(0);
                Iterator<PackageInfo> it = applist.iterator();
                while (it.hasNext()) {
                    PackageInfo pk = (PackageInfo) it.next();
                    if (PackageManager.PERMISSION_GRANTED == packageManager.checkPermission(Manifest.permission.ACCESS_FINE_LOCATION, pk.packageName)) //checking if the package is having INTERNET permission
                    {
                        results.add("" + pk.applicationInfo.loadLabel(packageManager));
                    }
                }

https://github.com/commonsguy/cw-andtuning/tree/master/TrafficMonitor

http://www.techrepublic.com/blog/app-builder/create-a-network-monitor-using-androids-trafficstats-class/774

http://agolovatyuk.blogspot.com/2012/04/android-traffic-statistics-inside.html

also check these links :)

Vanilla Boy
  • 258
  • 2
  • 12
  • Thanks for your reply. @Vanilla Boy, It looks like this code is checking which installed app is having the permission of the internet. Is there a way that I can record when does an app is using the internet or other recources? – Foreverniu Nov 13 '15 at 15:42
  • https://github.com/commonsguy/cw-andtuning/tree/master/TrafficMonitor ----------------------- http://www.techrepublic.com/blog/app-builder/create-a-network-monitor-using-androids-trafficstats-class/774 ------------------------ http://agolovatyuk.blogspot.com/2012/04/android-traffic-statistics-inside.htmlCheck these links brother.it may help you :) – Vanilla Boy Nov 13 '15 at 15:46