@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@SuppressWarnings("deprecation")
public static boolean isSideloadingEnabled(Context ctx) {
final ContentResolver cr = ctx.getContentResolver();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
//Pull from Secure settings for (API < 17)
return Settings.Secure.getInt(cr, Settings.Secure.INSTALL_NON_MARKET_APPS, 0) == 1;
} else {
//Setting was moved to Global settings in (API >= 17)
return Settings.Global.getInt(cr, Settings.Global.INSTALL_NON_MARKET_APPS, 0) == 1;
}
}
Javadoc for the INSTALL_NON_MARKET_APPS
states:
Whether the package installer should allow installation of apps downloaded from sources other than Google Play. 1 = allow installing from other sources 0 = only allow installing from Google Play