嘿,我想当用户尝试卸载应用时,会有密码解锁。我遵循以下代码:
android: require password when uninstall app
但清单中出现错误“android:description =”@ string / descript“” 请帮助我。严重陷入其中。谷歌也没有答案
答案 0 :(得分:0)
try the following code in your service
public static final String UNINSTALLER ="com.android.packageinstaller.UninstallerActivity";
private ActivityManager activityManager = null;
private ExecutorService executorService;
@Override
public void onCreate() {
super.onCreate();
executorService = Executors.newSingleThreadExecutor();
activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
LockerThread thread = new LockerThread();
executorService.submit(thread);
}
private void protactApp(String packname) {
Intent pwdIntent = null;
pwdIntent = new Intent("uninstaller.receiver");
sendBroadcast(pwdIntent);
}
class LockerThread implements Runnable {
private String lastname;
public LockerThread() {
}
@Override
public void run() {
ComponentName act = activityManager.getRunningTasks(1).get(0).topActivity;
String packname = act.getPackageName();
if (act.getClassName().equals(UNINSTALLER)) {
Log.d("Tag", "package to be uninstalled");
protactApp(UNINSTALLER);
}
}
从接收器中你可以在卸载应用程序时获取操作,这样你准备好的密码或模式的屏幕就可以在卸载之前启动,如applock应用程序
答案 1 :(得分:0)
它不会对4.3或更高版本有所帮助,但我发布了一个链接,您可以在其中找到解决方案以及为什么不能这样做的原因。 这是link。希望它能帮助您理解这一背景下的真正里程碑。