如何知道一个应用程序会在Android中被卸载? [英] How to know that an app is going to be uninstalled in android?

查看:394
本文介绍了如何知道一个应用程序会在Android中被卸载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要实现类似的AppLock应用程序在做。
如果它的设置将其设置为锁定应用程序卸载/安装,那么在卸载任何应用程序(precisely上点击卸载按钮)锁定屏幕出现这要求输入密码/模式。< BR> 只有在输入密码后,用户被允许卸载应用程序。

I want to implement something like AppLock application is doing.
If in its settings it is set to lock applications uninstall/install, then while uninstalling any app (precisely on clicking the Uninstall button) a lock screen comes which asks for a password/pattern.
Only after entering the password user is allowed to uninstall the app.

那是什么意图(或任何东西,我以为这是一个意图,但不知道),一个时得到的卸载按钮的点击?_爱又我不想要使其设备管理,正如我所提到的应用程序,确实需要为设备管理。
如果他们能做到这一点,那么有一些方法。 请大家帮帮忙。

What's that intent(or anything, I assume it to be an intent but not sure) that one get when Uninstall button is clicked?

Also I dont want to make it device admin, as the app I mentioned does require to be device admin.
If they can do it, then there is some way. Please help.

推荐答案

我已经找到一种方法。

I have found a way.

  1. 当你转到设置 - > 管理应用 - > 点击任何程序
    你的包额外的名义播出。

  1. When you go to Settings -> Manage Apps -> Click on any app.
    you get a broadcast with name of the package in extras.

当你点击的卸载按钮的屏幕上, 活动始终打开名称 com.android.uninstaller.UnistallerActivity

When you click on the Uninstall button on that screen, an activity is opened always name com.android.uninstaller.UnistallerActivity.

所以,要解决这个问题是1和2的步骤上述的组合方式。

So the solution to this problem is a combined way of 1 and 2 steps mentioned above.

在以往你在第一步中提到的意图和群众演员包含您的应用程序包的名称使用开始活动观察家 PackageManager ,通过它让高层最明显活动及其包装。
所以,现在,如果卸载活动启动,那么你可以肯定的是用户想卸载你的应用程序。

When ever you get the intent mentioned in first step and the extras contain the package name of your app start an activity watcher using PackageManager by which you get the top most visible activity and its package.
So now if uninstaller activity is launched then you can be sure that user wants to uninstall your app.

有后,你可以做必要的行动,以阻止他这样做。

There after you can do necessary action to stop him to do that.

这篇关于如何知道一个应用程序会在Android中被卸载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆