Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
278 views
in Technique[技术] by (71.8m points)

android - Require a password to uninstall/remove application

I would like to require that a user type a password before being allowed to uninstall/remove my application. How can I implement this functionality?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...