I am developing an android app for a company. Their employees must not use any other apps but the company-app,the preinstalled phone-app to make calls and the settings.
So I created a custom launcher and registered it as default. The launcher shows only the allowed apps. But the employees could open the settings and set the normal android launcher as default (and then use the internet for doing unallowed things or download malware) or uninstall my launcher.
Is there any possibility to prevent this without rooting? If I register the laucher as device administrator they could open the settings and disabling it.
Note: I have full access to the devices before they were delivered.
Best regards
I found a solution
1. I registered my app as boot-receiver
2. I created a service which tests which activity is in foreground (if it is from the whitelist: OK, otherwise: my app comes to foreground, blocks the foreground-activity and shows the user a warning "don't do this")
The next problem was: the user should be able to use the settings (for wifi), so he could uninstall my app.
3. Register my app as device admin (the user is unable to uninstall or force-stop my app until he unregister it as device-admin)
While testing which activity is in foreground, the service tests if the app is still device-admin. If it isn't device-admin, all apps were blocked until the app is device-admin again (the dialog pops up).
Related
Events:
1.USB device plugged in.
Prompt appears saying: "Open appName when this USB device is connected?"
Press cancel -> app stays open | press okay -> app restarts
Required behaviour: The app either does not show the dialog and automatically opens the app when it's not in the foreground, or, when the app is in the foreground then when the user presses okay the app does not restart.
Attempted solution: I've tried making sure every Activity's launch mode is set to "SingleTask". This solution worked here but when I did the same thing the app still restarted.
Question in a nutshell: How do I stop my app restarting when the user says to open the app when the device is connected? Or, how do I stop this prompt entirely whilst still enabling my app to start when this USB device is connected?
I've seen similar questions which deal with stopping a prompt showing which asks whether the app should be allowed to access the connected device, but, my issue is dealing with a different prompt.
Thanks in advance.
the app uses an IntentFilter with an AppChooser or Launcher dialog https://developer.android.com/guide/components/intents-filters.html
this always happens when you use an IntentFilter on android.hardware.usb.action.USB_DEVICE_ATTACHED. Another possibility is that the dialog is an AppChooser or launcher dialog that is invoked when there are multiple apps (or multiple instances of the same / your app) that capture the USB attach event . This is why when you press Cancel the app stays open.
Using an intent filter
To have your application discover a particular USB device, you can
specify an intent filter to filter for the
android.hardware.usb.action.USB_DEVICE_ATTACHED intent. Along with
this intent filter, you need to specify a resource file that specifies
properties of the USB device, such as product and vendor ID. When
users connect a device that matches your device filter, the system
presents them with a dialog that asks if they want to start your
application. If users accept, your application automatically has
permission to access the device until the device is disconnected.
https://developer.android.com/guide/topics/connectivity/usb/host.html
this is a systems dialog that is internally linked to the android.hardware.usb.action.USB_DEVICE_ATTACHED event so disabling it will be difficult. there is the possibility to use <activity-alias>, https://developer.android.com/guide/topics/manifest/activity-alias-element.html you can route intents with it:
http://www.stackoverflow.com/questions/40182096/usb-permissions-without-prompt/40182413#40182413
http://blog.danlew.net/2014/01/16/preserve-your-launchers-use-activity-alias/
(Is there any way to have one and only one instance of each activity?)
I want to create an app only for my phone, that runs all the time in background - and you should never stop that service from running.
My goal is, that this app is sending the current location data to my computer at home - to get it back, when it has been stolen for example, or when I lost it.
The problem is, that it is not possible to start a service without having an activity and/or launcher icon (because the thief should not know this).
But: My phone is rooted, so is it possible to start the service anyway?
And also: When I place my APK into the /system/app partition, will the APK persist after doing a factory reset?
Yes, you can. Rooting your phone doesn't matter for what you want to do, and if anyone tried to factory reset your phone, your app will still not be deleted, if you put your apk in /system/app partition as you said. It will react as if it was a normal system app. But of course, you must also set the correct permissions for your app when moving it to the system folder to be able to work.
And to prevent the thief from knowing your app, you can just name your app with an ambiguous name and without an icon that describes what your app does, because your app will still be visible in your application manager from your phone settings. Along with that, you can do the following:
To create an app that does not have an icon in the Home Launcher, just remove the intent filter android.intent.category.LAUNCHER of your activity from the AppManifest.xml.
To implement your background application, it strongly depends on what you want to do. You can create a Service for long running tasks, BroadcastReceiver to react to specific events or activities with intent filters.
Edit:
In order to let your app work automatically, you must put your app in this folder /system/priv-app. This way, your app will be started everytime you boot your device.
I want to make an android app that runs as the only app on the android device. If the unit is reset I want this app to start up and run.
The reason for this is we are going to be buying these special 7 inch wall mounted tablets which have android OS on them (here is a link to the device: http://www.geekland.co/7-Android-42-Panel-PC-Wall-or-Desk-Mounted-Tablet-with-RJ45-GK-Q896.htm). And we are going to be programming an app that does various things.
However, it is imperative that the app cannot be exited and that if the system restarts, that app is what runs. We don't want random people messing with the device. We want to restrict everything just to that app.
Of course, maybe with an admin password you would be able to exit the app.
Can this be done somehow within an android app? Or does this call for, I don't know, making some new android OS clone or something? (something I'm not sure of how to do).
As I know there are few ways to do this.
Override buttons as in here
Write a home screen application as in here
Lock apps using apps similar to AppLock some can even lock system apps and settings
If the devices are running Lollipop or newer, you can do this with the Task Locking API. First you need to make your app (or some other app) the device owner and grant your app the lock task permission so that locking can be done without user confirmation. Then just add a receiver in your manifest for the BOOT_COMPLETED intent and lock the task when the app starts.
I wrote an open source app that acts as the device owner and simplifies granting lock task permission to your own apps.
I am building a android application and I want to run this application in such a way that once it is installed in a device, that particular device should not be allowed to install any other applications. Basically restrict app installation to just one application(i.e mine).
I have looked at few options such a home launcher and tried but this allows me to install other applications as well. Is there a methodology where I can block other apps from getting installed in my device? Thank you.
You should take a look at this page:
http://developer.android.com/reference/android/content/Intent.html#ACTION_PACKAGE_ADDED
When a package has been installed, you should receive a new broadcast event with this intent.
Basically, you have to force uninstall or lock the app with that package id. You'll probably need to be root on the device if you want to avoid a new activity to show up.
Is it possible to have an application run on a device in such a way that it is the only application that can ever run and also prevent the user from using the operating system at all? Tapping on the Home key or Back button would not exit the application and allow the user to have access to anything. If the device boots up, only this application would run.
This would be desirable in situations where devices are installed at a business for point of sales purpose or possibly where the device acts like a terminal in public places.
You can achieve what you're describing by writing your app to replace the home screen (Launcher). From there, you control what other apps will run.
The Android SDK has a working Launcher project you can start from.
Be careful to allow some method of running a more powerful app (even if it's just enabling ADB access) -- otherwise you could leave your device in a state of needing a factory reset before it can be modified.
Yes, you can override the back and home button behaviour.
Start app, override all buttons, and the user cant exit the app, evil, but should work in your scenario.
info here