Android - get INSTALL_NON_MARKET_APPS boolean -
i trying around install_non_market_apps option has 2 different versions. pre-17 api level , 17+. null pointer exception when run this:
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; }
i believe api level 3 settings.system
variable depreciated , changed on settings.secure
, in api level 17 changed on settings.global
.
also, believe method call requires context content resolver.
boolean unknownsource = false; if (build.version.sdk_int < 3) { unknownsource = settings.system.getint(getcontentresolver(), settings.system.install_non_market_apps, 0) == 1; } else if (build.version.sdk_int < 17) { unknownsource = settings.secure.getint(getcontentresolver(), settings.secure.install_non_market_apps, 0) == 1; } else { unknownsource = settings.global.getint(getcontentresolver(), settings.global.install_non_market_apps, 0) == 1; }
Comments
Post a Comment