我试图绕过具有两个不同版本的 INSTALL_NON_MARKET_APPS 选项。17 岁之前的 API 级别和 17 岁以上。运行此命令时出现空指针异常:
boolean unknownSource = false;
if (Build.VERSION.SDK_INT < 17) {
unknownSource = Settings.Secure.getInt(null, Settings.Secure.INSTALL_NON_MARKET_APPS, 0) == 1;
} else {
unknownSource = Settings.Global.getInt(null, Settings.Global.INSTALL_NON_MARKET_APPS, 0) == 1;
}