是否可以阻止在根设备上安装android应用程序?我想阻止在根设备上安装android应用程序。如何做到这一点?
发布于 2021-11-03 05:59:44
我不知道这是否可以做到,但你能做的就是让你的应用程序在根设备上不可用,这意味着即使安装了它,用户也无法使用它。
要做到这一点,你需要做的就是通过下面的任何一种方法来确定你的应用程序是否运行在有根的设备上(android代码)
public class RootUtil {
public static boolean isDeviceRooted() {
return checkRootMethod1() || checkRootMethod2() || checkRootMethod3();
}
private static boolean checkRootMethod1() {
String buildTags = android.os.Build.TAGS;
return buildTags != null && buildTags.contains("test-keys");
}
private static boolean checkRootMethod2() {
String[] paths = { "/system/app/Superuser.apk", "/sbin/su", "/system/bin/su", "/system/xbin/su", "/data/local/xbin/su", "/data/local/bin/su", "/system/sd/xbin/su",
"/system/bin/failsafe/su", "/data/local/su", "/su/bin/su"};
for (String path : paths) {
if (new File(path).exists()) return true;
}
return false;
}
private static boolean checkRootMethod3() {
Process process = null;
try {
process = Runtime.getRuntime().exec(new String[] { "/system/xbin/which", "su" });
BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
if (in.readLine() != null) return true;
return false;
} catch (Throwable t) {
return false;
} finally {
if (process != null) process.destroy();
}
}
}然后如果是device is rooted,那么navigate到一个“带有消息的应用程序不能在带有exit button的设备上运行”这样的消息。
颤振的
您可以使用pub.dev提供的trust_fall包,
import 'package:trust_fall/trust_fall.dart';
bool isJailBroken = await TrustFall.isJailBroken;https://stackoverflow.com/questions/69819985
复制相似问题