Locking down an android application. Ideas?
android
Solution
The problem you've got is that when described as application for parent to monitor their child what you want sounds benign, viewed differently it sounds a bit like malware, as you want an application that:
- Cannot be uninstalled
- Emails home without informing the user
As has been said, you won't be able to prevent uninstallation without a custom build of Android. There are events which are sent on the uninstall of an application but these cannot be intercepted by the app being removed. (So I guess you could install your application and a watchdog application which monitor each other for removal, but if the child goes somewhere with no signal and removes both then they will disappear silently since they can't call home with no internet access.)
Another problem is sending email. The usual way to send an email in Android is through using an `Intent` to switch to an Email application with address and content filled in, but this requires confirmation from the user to send, which won't help you and the child could just decline to send the warning email.
So instead of calling home when the application is removed, what you're going to have to do is call home every day when all is well; if the application doesn't call in then the parent knows there is a problem. You could write a `Service` which is calls home and and is started daily by an `AlarmManager`.
For calling in you're either going to have to connect to a URL via HTTP or write your own code to send emails using SMTP, since you can't send emails silently out of the box. I'd use the former if possible, otherwise you'll have to store your own SMTP configuration as you can't "borrow" this from another appl.
You could display the email application each day and get the child to send the all-is-well email, but the problem there is that the child could easily recreate the email by hand each and send it without the application running unless you went so far as to cryptographically sign and verify each email.
Problem
I'm toying around with an idea for an app that, in theory, a parent would install on a phone he/she gives to his/her child. So, main problem is, how would I be able to prevent the child from just uninstalling the application? Any ideas on how to solve this? I'm really doubtful something like this exists but thought asking here was a good way to find out if there were any tricks. EDIT: If there's no way to prevent this from happening; how about this: upon uninstall, do something (e.g. send an email to a previously configured email address). This could serve as a disincentive for the child to uninstall the app as the parent could find out about it. Of course, an industrious miscreant would just turn on airplane mode and then uninstall but I'm just fishing for ideas at this point.