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.
Related
A client of mine is requesting for a very specific functionality, to keep the application always active, even after the user force kills it. He wants to ensure that the users have the application active at any time while using the device on which it is installed (the devices are managed in a constrained environment).
I've done some research on it, and already enabled background services for sending the user's location, but if they force kill the app then we are unable to send locations to the server. We've seen other apps do it, but wonder how they do it.
According to https://stackoverflow.com/a/34573169/640907 it should be possible in Android. We also found https://ssaurel.medium.com/how-to-auto-restart-an-android-application-after-a-crash-or-a-force-close-error-1a361677c0ce but I don't think this will work for our use-case, as the user can close the application without "force kill" aswell..
Anyone knows how to achieve this for a Flutter application?
I am trying to build an application that will, upon user's consent, freeze the phone for some time during which period the user can't really close the application or move out to another. Is there a way to do this?
You can not "freeze" the phone, but there is a way to block usage:
you can create a full screen overlay.
Here is a random sample from the internet.
This requires a special permission, and may be seen as a malware behavior so your app may not be allow in the Google Play Store.
And you have to be very careful with this, since if you do not remove it in time the user will be forced to reboot the phone.
I've seen some "app locking" solutions in the Google Play store and I was wondering how those apps work. I'd like to build something similar.
I realize that this might require some special permission or maybe request the app to be added as device administrator.
Is there some broadcast that is triggered just before an app is launched that I can intercept and do some action (e.g. launch an activity that will request the user to fill a password)? I've read some lengthy discussions how this is not a good idea and the only idea is to have a background service that will continuously poll the running processes and check for changes, but I think retrieving this list every second and checking it for chances is not good for the battery and I think other app locking apps out there must be using a different approch.
If possible, without the need for a rooted phone.
With User's permission, I want to be able to stop certain apps from opening at certain times of the day.
What I want to do is - when user clicks on an app icon, the app does not open - it just shows you a "Toast" message.
Can this be done?
I have researched online and cannot find a way to either do this or even fake the effect.
To actually stop the apps from launching would require your application to be signed by the same cert as the os (from the manufacturer), or to be run as root (on rooted devices). Samsung offers a program for Samsung SAFE (I believe SAFE is the one) in which you pay them to sign your application, and use their APIs for this kind of thing.
A way to "fake" this effect would be to run a background service which watches the foreground application, and if it is blacklisted (not allowed) then close it. This poses other issues such as timing, and still allowing tasks to start in the background.
So in short; No, this cannot be done unless you have a partnership with hardware vendors. And you can "fake" it but it won't be very reliable.
What is the best way to let my users perform an application update?
Is there any way to force device reboot after the update? I'm asking this because my application registers some behavior on boot.
Please note, the application would not be published in the Market.
Update:
My app will be preinstalled on a set of ~100 handsets.
Should I periodically call a webservice that will inform the device about upgrade available, and then, redirect to an .apk file within a webkit view?
What is the best way to let my users
perform an application update?
Via the same way they got the app on their device in the first place, presumably. If they are getting the app via firmware, they get app updates via firmware updates. If they are downloading your app via your Web site, they get app updates via your Web site.
Is there any way to force device
reboot after the update?
No, thank goodness.
I'm asking this because my application
registers some behavior on boot.
There is some way you can be notified that your package was updated, though I do not have the technique handy right now. Just run your on-boot logic there for the first round, then subsequent reboots (if any) will be handled by the on-boot logic itself.