1

I want to know how to detect when an external app runs one of this methods. I'm working with some classmates in a project where we want to examinate the response time of other applications. The idea is to measure the time between the run of each method to get an aproximation of the response time when opening the app.

Is this possible to achieve?

2 Answers2

1

Android apps are sandboxed and only expose content that they intend to expose. The methods you name are part of components that cannot be accessed directly from the "outside" world. In other ways, if an app wanted you to know when those methods are being called, they will expose that information (i.e. sending a Broadcast or maybe storing the information in a ContentProvider). You can try and see if you can get some information out of the logcat, but I cannot assure how accurate and consistent it will be.

Emmanuel
  • 13,083
  • 4
  • 39
  • 53
0

This is imprecise, but I would monitor logcat activity. Depending on the device/VM/AVD logcat is super active during transitions (such as back-grounding and foregrounding) and idle when an app is awaiting user input.

EDIT: Other than that, if you can do your analysis off the device, perhaps look into using DDMS?

Chadroid
  • 43
  • 5
  • But i want to measure the response time, from a service, so i think the logcat wont help me in this case. Correct me if i am wrong. – Leandro Temperoni May 23 '14 at 15:58
  • There's always reading logcat [programatically](http://stackoverflow.com/questions/12692103/read-logcat-programmatically-within-application) on the device. In the past I've parsed logcat using adb and a python script to profile applications. – Chadroid May 23 '14 at 16:02
  • Hey, i was able to read the real response time thrown by the Activity Manager. Thanks for the help!! – Leandro Temperoni May 23 '14 at 18:02
  • Hi, i am reading the logcat by using READ_LOGS permission. This permission is not available in devices running Jelly Bean and above(4.1 and above). Do you know if there is any other way of reading the ActivityManager logs in jelly bean ? – Leandro Temperoni May 25 '14 at 19:50
  • There are a couple of questions [here](http://stackoverflow.com/questions/11461650/read-logs-permission-on-jelly-bean-api-16) and [here](http://stackoverflow.com/questions/11371021/reading-activitymanager-logs-on-a-jelly-bean-device) of using a package manager to grant the permission. However, if you want an app-driven reader it looks like google engineered that capability away. Unless your app is going to run on root devices, this appears to be a standing constraint. – Chadroid May 27 '14 at 13:29
  • Yes, i am afraid i am not able to run the app on root devices. Will check the links, thanks again. – Leandro Temperoni May 27 '14 at 17:07