You could do this by:
- The first time your app is installed, install a separate application/package (“watcher”).
- The only classes “watcher” contains is a BroadcastReceiver that listens for
ACTION_PACKAGE_REMOVED
- Add a BroadcastReceiver to your application that also listens for
ACTION_PACKAGE_REMOVED
- When a intent is broadcast to one of your receivers, check if the other component is still installed. If is isn’t (the user just uninstalled it), prompt for the password – if it’s wrong, reinstall the other component. If it’s right, uninstall yourself.