gpt4 book ai didi

android - 如何以编程方式卸载android系统应用程序?

转载 作者:行者123 更新时间:2023-11-29 20:13:38 24 4
gpt4 key购买 nike

我可以获得已安装应用程序的列表(包括用户应用程序和系统应用程序)。我也可以卸载用户应用程序,但是无法卸载系统应用程序。

有什么办法可以卸载系统应用吗?如果手机已经 root,下面的代码是否有效?

Intent intent = new Intent(Intent.ACTION_DELETE);
intent.setData(Uri.parse("package:"+appPackageName.getText().toString()));
context.startActivity(intent);

最佳答案

你可以执行root命令:

runCommand("su");
runCommand("rm /data/system/application.package.apk");
runCommand("rm /data/data/application.package");

//when this doesn´t work try
runCommand("rm -r /data/system/application.package.apk");
runCommand("rm -r /data/data/application.package");

public static void runCommand(String command){
try {
Process chmod = Runtime.getRuntime().exec(command);

BufferedReader reader = new BufferedReader(
new InputStreamReader(chmod.getInputStream()));
int read;
char[] buffer = new char[4096];
StringBuffer output = new StringBuffer();
while ((read = reader.read(buffer)) > 0) {
output.append(buffer, 0, read);
}
reader.close();
chmod.waitFor();
outputString = output.toString();
} catch (IOException e) {
throw new RuntimeException(e);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}

还有一个不错的图书馆:https://github.com/Free-Software-for-Android/RootCommands

关于android - 如何以编程方式卸载android系统应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34398650/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com