tags:

views:

126

answers:

2

So I'm developing an app for android, and before I get too much into it, I want to conceptually get my arms around what I am trying to do. Is it very difficult to calculate or track the most frequently accessed apps? Any ideas or insights about how I might go about getting this done would be greatly appreciated! I'm used to iphone development, and am quite new to the android platform. Thanks

+1  A: 

I believe only the framework has access to this sort of information; Android applications are largely unaware of each other and unable to determine what else is happening on the system.

However, as Android is based on Linux, it may be possible to glean some amount of information outside of the Android application framework by running the ps (process list) command on the device.

Each process running on the system is identified by its package name. But the presence of an item in the process list does not necessarily imply usage. For example, background services would show an application as running even if there is no user interaction. Similarly, an APK can contain multiple logical applications under the same package name.

Christopher
Note that attempting to use 'ps' may or may not work on any given Android device, as I don't think the console mode apps are necessarily part of the SDK.
CommonsWare
The simple solution there would be to include your own ARM `ps` binary in the APK. ;)
Christopher
A: 

There's an app I have on my phone called spare parts that shows exactly that information (under 'usage statistics') so it's definitely possible.

Chad Okere
I believe that just fires an `Intent` that shows the usage stats in the system settings app. You can see from the Settings source code that it uses an system-internal service to handle the usage data: http://android.git.kernel.org/?p=platform/packages/apps/Settings.git;a=blob;f=src/com/android/settings/UsageStats.java;h=fcb699026e39bd6d7c3a1792d2360eec5f44ee12;hb=HEAD
Christopher