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.
Related
[EDITED]
I want to create an application that discourages the usage of social media applications. Like if they open Instagram or something then the Flutter app will know.
How would I detect if another application (Such as Instagram or Twitter) is open when my Flutter app is opened?
If this is difficult to implement in Flutter, can anyone suggest some other languages or code for this functionality?
Thanks!!
It is possible at least on Android. I do not program for IOS so I can't say for sure. As #Gaurav pointed out, the solution will need to be custom-made and it probably won't be specific to Flutter. If you are willing to work outside Flutter than it is possible.
Once again, the following solutions are for Android devices:
Solution 1: Since you are targeting social media apps you can lookup the public intents of each app (i.e. Facebook, WhatsApp, etc...) find out the names of the intents they are broadcasting and add a broadcast receiver in your application. Many will say this is not a good idea because the app developer's themselves could change the intents and that you shouldn't listen for anything that hasn't been declared for public use. They are probably right, but this discussion is about how to detect the other apps launching and this method works.
Simply google how to add a broadcast receiver, a good example can be found here.
There are websites that contain databases for a lot of broadcast intents for popular Android applications, but if you have trouble finding the name of a particular one then I'd suggest using ADB to find it. For example, Facebook would be:
adb shell pm dump com.facebook.katana | grep ' filter' | cut -d ' ' -f 12
In some versions of Android broadcast intents do not work, however registering it in the application has worked pretty well for myself.
Once you have a listener setup properly, then you can detect the app when the user launches it and process it accordingly.
Solution 2: You could monitor the processes on the Android device via "Process" and/or "PackageManager" and see when one of the social media applications popup. This method is not very reliable because apps are on all the time and just because they're in the process list doesn't mean they are actively being used.
Solution 3: Once again, this is a very "hacky" solution, but you could listen to the logs on each device. Basically get the output of console logs, read the last 100 lines and see if the app is doing something. If so, then you may be able to determine if the app is active. The biggest problem with this solution (besides trying to read logs on all your user's devices) is that this is not an instant solution and may require special privileges depending on the device you're working on. You would also probably need to setup a service that actively listens and reads the logs, which might cause some significant battery usage.
I'm building an app that needs to restrict which apps can be run along with it.
In example, when my app is running (foreground or background) I can allow user to run only GoogleMaps, and MusicPlayer.
I've read a bit about Device Policy Controller and creating profiles, and up to some point it seems to have the feature I need, but it is designed for enterprise deployment, and user needs to encrypt their phone beforehand. Is creating personalized profiles a way to go?
My other idea was to run a service that each few milliseconds check if there is any forbidden app running and finish it, but it seems to be not robust.
Is there any way of handling this problem programmatically?
I don't think that Device Policy Controller is a right thing for you.
And you can't just kill other apps without root.
So some kind of user-friendly way to achieve the goal is to check running apps list with ActivityManager.getRunningAppProcesses and to notify user that he has to finish particular apps to use your app.
I am working on an Android enterprise application that targets limited mobile devices which help owner to track the user/device status (like GPS, Calls logs) remotely. I managed to implement these basics features to my application. Challenge that I'm facing now is the end users who traveling away with the device can force stop the application or can revoke some permissions(above Marshmallow) to prevent them self from being tracked remotely by the owner.
First of all is it possible to make such an application?
If yes, what are APIs given for such applications development?
Note - All the targeted devices are rooted anything I can get advantage of that.
Is there are any special APIs available for developments of those applications which work only on Rooted devices?
According to your requirement i will suggest you to look deep into the android Service.
As You might also have a look on the persistent service,
You can only make your service persistent if you are developing system apps. This service is basically unkillable.
Here is some write up for persistent service
Hopefully this might help you.
But for non-system applications, startForeground is your best option.
In Android, I want to know if I can receive the event whenever I open Android Message Application?
I tried get task in foreground but that didn't work in service as for that service has to continuously poll
Kindly guide
The only way you can achieve this is by polling. No other way :(
I can receive the event whenever I open Android Message Application?
No.
First, there are thousands of Android device models, spanning hundreds of manufacturers. There are dozens upon dozens of "Android Message Application" pre-installed across the device models, as manufacturers often provide their own. There are also hundreds of "Android Message Applications" available on the Play Store and elsewhere. You have no great way to know what apps are and are not "Android Messaging Applications", though you could try to examine <intent-filter> structures and deduce which ones might meet your requirements.
Second, there are no events posted to ordinary Android SDK apps when other apps or their activities start. Even some of the polling techniques that you mention will not work on Android 5.0+, and any that still do work represent bugs that should get fixed. Google is locking down this information for privacy and security reasons, such as to help prevent OAuth hijacking attacks like this one.
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/