7

I wish to know is it possible to write an android app that when it runs at the background, it can track user activities?(Such as what other app did the user used, what phone number did user dial, the GPS location for user, etc) Cause I am not sure can a single android app react to other application, does anyone know the answer? Thanks

JLTChiu
  • 983
  • 3
  • 12
  • 28

4 Answers4

6

In the general case, no, you can't. And users would probably prefer it so.

Once this has been said, there are certain partial solutions. Sometimes the system is so helpful that it will publish Intents reflecting user actions: for example when the user uninstalls an app -- with the caveat that you don't get that intent on the app itself being uninstalled.

It used to be the case that before Jelly Bean (4.1) apps could read the log that other applications publish and try to extract info from there, but it was a cumbersome, error prone, ungrateful task. For example, the browser shows nothing when it navigates to a certain page. You may read the logs for a while with adb logcat to get a feeling of what was possible and what isn't. This action requires the relevant permission, which cannot be held by regular apps now.

Thanks to @WebnetMobile for the heads up about logs and to @CommonsWare for the link, see the comments below.

Community
  • 1
  • 1
alexfernandez
  • 1,938
  • 3
  • 19
  • 30
  • 1
    readong logs via adb is different thing than reading logs on device. It has changed recently and apps can only read own logs now. Which, for legitimate use is sametimes a problem, but in general, for non devs I second that move. – Marcin Orlowski Nov 21 '12 at 18:35
  • Care to share a link that describes this change? – alexfernandez Nov 21 '12 at 18:37
1

Yes you can.

You can look here for instance about phone info: Track a phone call duration

or

http://www.anddev.org/video-tut_-_querying_and_displaying_the_calllog-t169.html

There is a way to let Android and users know you are using and accessing their data for them to determine if they will allow it.

I am unsure you can simply access any app, but in theory if you know how to read the saved files that might be possible.

For instance Runtime.getRuntime().exec("ls -l /proc"); will get you the "proc" root folder with lots of data you might need there. This might have been changed, I am not sure, and I also don't know what you need.

Perhaps to get running process try:

public static boolean getApplications(final Context context) {
   ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
   List<RunningTaskInfo> tasks = am.getRunningTasks(1);
}

For this to work you should include this in your AndroidManifest.xml

<uses-permission android:name="android.permission.GET_TASKS" />

See more about it: http://developer.android.com/reference/android/app/ActivityManager.html#getRunningAppProcesses%28%29

Community
  • 1
  • 1
msj121
  • 2,812
  • 3
  • 28
  • 55
  • I only need to know "What app did the user opened." But I am not sure is that accessible for other apps. – JLTChiu Nov 21 '12 at 18:41
  • To be more precise, I wish to have a report like this 10:00~10:05 App A 10:05~10:07 Call 12345678 10:20~10:23 App B 11:10~11:20 Receive from 98765432 Something like this is more than enough, is that possible – JLTChiu Nov 21 '12 at 18:45
  • I haven't done it myself, but it seems there are ways of getting the data, the question is are these holes that will be filled as someone mentioned, or open protocol that Google will continue you to use. If you do find something and intend to make a business of it, you can always try contacting Google to see if they are intending on closing it or not I suppose. – msj121 Nov 21 '12 at 18:51
0

You certainly could but I think reporting that data back to you, unbeknownst to the user, via the internet, would be considered spyware and almost certainly illegal in most jurisdictions.

amphibient
  • 29,770
  • 54
  • 146
  • 240
0

Fortunately spying users at that level should not be possible. Certain features can be achieved with abusing bugs in android which sooner than later will be fixed. I see absolutely no reason for you to know what number I am calling and where I've been lately. It's basically none of your business.

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
  • Thanks for your quick response. I was thinking is it possible to do an app like that for data collection, seems now I should find some other way to do that. – JLTChiu Nov 21 '12 at 18:39