the是使用上述设置的代码:
boolean isNonPlayAppAllowed = Settings.Secure.getInt(getContentResolver(), Settings.Secure.INSTALL_NON_MARKET_APPS) == 1;
此外,向用户显示设置可能很有用:
if (!isNonPlayAppAllowed) {
startActivity(new Intent(android.provider.Settings.ACTION_SECURITY_SETTINGS));
}
此设置称为“
install_non_market_app”(单击文档)
.。(我基本上已经键入了这个问题,当我发现文档中隐藏了一个不同的名称中的答案时,我决定发布问题和自我答案,因为这不是微不足道的。)
applicationContext.packageManager.canRequestPackageInstalls()