I am new to android development. I came to know that Intent and Intent filters can be used to share data among applications but I wonder if it is possible to design an android application which can extract some specific information from other applications while running in the background. For example, if the user is using whatsapp it may get know the call drop rate or if a video is being played at user terminal in YouTube, Facebook or Netflix, it will get buffer playtime, video bitrate etc. I will be very grateful if answer to this question is provided with an example.
No, mostly no.
However, as wrote Tim Castelijns, if the 'target' app allows it, like via a content provider, its possible.
On a rooted device, after long hours of reverse engineering the targeted apps, it MAY also be possible to get some info. Only from rooted devices too.
Other case is you write several app and design that they can communicate together, like via intents, content providers.
There is also possible to get the list of running apps (user must permit it)
In Android, each application is running on its own "sandbox" that is supposed to be isolated from the rest of the applications running on the device.
In order for an application to communicate with other applications, the Android framework supplies several mechanisms to send/receive data to/from other applications: Intents, IPC (AIDL), Content Providers etc...
Each application that wants to expose its data to other applications on the device needs to implement an interface using one or more of the mechanisms described above.
That means that if an application doesn't implement an interface to expose its data or inner workings, it won't be possible for another application to access this information.
Keep in mind that some applications choose to save some of their data on publicly available disk spaces (i.e. a camera that takes pictures might save them on the SDcard that is accessible by all applications). In that case, if you know what to look for, you can tell certain things about certain applications.
In addition, the Android operation system exposes the states of several global settings such as: Device's connectivity state, Battery state, currently opened Bluetooth interfaces, running applications, last executed apps etc...
This configurations might give you an overall idea of what is happening on the device.
As indicated in other answers, you're mostly limited to what apps will explicitly make available to you; in fact, well-engineered apps will generally try to prevent "information leakage" beyond what they actually want to make available.
Some other people mentioned Content Providers but the one other construct to look into is Broadcasts. If an app broadcasts an intent locally (i.e. is using the Local Broadcast Manager) you won't be able to see it but if they're using a "system-wide" broadcast or receiving another "system-wide" broadcast you can receive the same event.
Related
I have a requirement to develop an application which will monitor the usage of the phone cameras and record information about when/where a photo was taken. I am aware that this information is typically recorded in the image metadata but I have a need to add additional information to this and record it separately from the image.
In essence, I would like to know:
Any time the camera is opened, closed, activated (brought to front), deactivated (user switches to another app)
Any time the camera saes a file; either a photo or a video
Know the above regardless of whether the camera was launched directly or via another app
Know the above regardless of whether the caller used an intent or the camera APIs.
Are there good APIs to use for this? Is it possible to replace low-level interfaces to act as a man-in-the-middle? Is it possible from Java or would this necessarily be in C/C++?
At the moment my only solution would be to monitor the logs in a continuous service to identify everything I could from the above and implement a FileObserver to check for file creation/modification times.
Are there good APIs to use for this?
There are no APIs for this, for obvious privacy and security reasons.
Is it possible to replace low-level interfaces to act as a man-in-the-middle?
On a rooted device, perhaps. In a custom ROM, definitely. In an ordinary Android device, no, for obvious privacy and security reasons.
would be to monitor the logs in a continuous service to identify everything I could from the above
You have no access to logs, other than those generated by your own process, on Android 4.1+, except on rooted devices or from a custom ROM.
and implement a FileObserver to check for file creation/modification times
There is no requirement for a camera app to store a file in a place for which you have filesystem access.
There is an android application I am planning to write, that will be used as an "always on" application (kiosk-mode) used on Android tablets running restaurant menu. Today, I already have a rudimentary application, but it is not quite what might qualify as kiosk-mode, since sometimes users close the application.
I wanted to see if there is a way to monitor the application remotely (or on device itself) and automatically restart it, s.t. it comes the foreground application ?
Of course, I'd prefer to remotely monitor for some remote customer service. It is not exactly essential to view (in remote desktop / vnc sense), but gather information like application health (running in foreground or not), get it's logs etc. Now I understand that on an unrooted device an applications log is not visible to other applications. So I was wondering if I could design my application to create light logs or status information, in a non-standard way, that could be shared by my other monitoring application.
While I get a feel that I am reinventing the wheel, since requirements like these seem far-from-unique, but in my search haven't found much beyond the standard 'screen cast' / 'screen share' applications... most of which either don't work too well (especially without root), or need one to jump through hoops to get them working.
There are ways to monitor activities of your application. There are utilities available to help you keep logs of events carried out by the users of the application. Like getting statistical information. They are typically Mobile Analytics tools.
Check this for instance: https://mixpanel.com/
This for example can help to keep track of events fired by the application. You can even send mails and notification to the users. There are similar tools available. For instance Google Analytics for Mobile Apps
The other possibility is to use Google Cloud Messaging. I believe this is even more powerful, which may help us to control our application to some extent. You may find this of help: http://hmkcode.com/android-google-cloud-messaging-tutorial/
I'm currently working on a productivity app. One of the features includes obtaining an information about apps that are started by the user
For example I would like to obtain information that the user has started the Youtube app or listen for a specific Intent being sent without registrating a BroadcastReceiver
Is this even possible?
You cannot intercept intents sent to other apps by extending the BroadcastReceiver abstract class for obvious security reasons. So, basically, this is not allowed using conventional features (or APIs) of the Android SDK. There might be some hacks out there that could work, but they're all hacks at the end of the day which are not guaranteed to work, for example there are some articles proposing to read the system's log, it used to work in older api levels but not anymore...see some references below and make sure you read the comments as well...
Android, Detect when other apps are launched
Detect when user launches a new application on an Android device
In simple words, you can't do that. Note, that having root is a complete different story
I am wondering if it is possible to launch a 3rd-party application from within my own application. I understand that Android runs in a sandbox, and so I am not too optimistic about this being possible.
I read the following here: http://source.android.com/tech/security/index.html:
"This sets up a kernel-level Application Sandbox. The kernel enforces security between applications and the system at the process level through standard Linux facilities, such as user and group IDs that are assigned to applications. By default, applications cannot interact with each other and applications have limited access to the operating system. If application A tries to do something malicious like read application B's data or dial the phone without permission (which is a separate application), then the operating system protects against this because application A does not have the appropriate user privileges. The sandbox is simple, auditable, and based on decades-old UNIX-style user separation of processes and file permissions."
Essentially, I want to launch some 3rd-party application that can scan and decode a barcode, and then have that data available to my own application. As I said, I doubt that this is possible, but surely someone must have encountered this before, and maybe found a compromise.
Yes it is possible if you have appropriate permissions to do that. Lot of applications use that feature to avoid writing the feature in their own app. Look into content providers as you are asking another content provider to scan barcode an provide you the data.
http://developer.android.com/guide/topics/providers/content-providers.html
As far as I know, there is no way to control over the activities occurring in an app in android phones unless the application that you want to log/monitor is written by you.
I wonder is it really like that or is there any possible way to do this? For example, is it possible to control over emails which, let's say, who I sent an email to in an android phone?
It is not possible to "just log it". Some events are possible to catch in broadcast receivers in a logging application. The user will get notified by particular event sniffing when installing such an application, by approving the permissions request.
It's generally possible to add instrumentation for security purposes to apps where they interface to the sdk api's, either by modifying the platform (rooted phone) or by decompiling, modifying, and recompiling the app using apktool.
possible of course does not mean trivially easy.