Question

I have very confusing problem,

If I make a change in anywhere, At the "Global.getInt" part (last line), there is an error

"Call requires API level 17 (current min is 4): android.provider.Settings.Global#getInt"

after making Project-> Clean, red error disappearing itself. But this error comes very often Why?

   public void buton2(View view) throws SettingNotFoundException{
    boolean isNonPlayAppAllowed = false;
 {

     if (Build.VERSION.SDK_INT < 5) {

        isNonPlayAppAllowed = Settings.System.getInt(getContentResolver(), Settings.System.INSTALL_NON_MARKET_APPS) == 1;
        }
        else if (Build.VERSION.SDK_INT < 17) {

            isNonPlayAppAllowed = Settings.Secure.getInt(getContentResolver(), Settings.Secure.INSTALL_NON_MARKET_APPS) == 1;
        } else {
            isNonPlayAppAllowed = Settings.Global.getInt(getContentResolver(), Settings.Global.INSTALL_NON_MARKET_APPS) == 1;


        }

Thanks!

Was it helpful?

Solution

Call requires API level 17 (current min is 4): android.provider.Settings.Global#getInt

It tells you that your code contains a method that was added in API 17 so the compiler is complaining. Now because you're doing your checks in regards of what API is on the phone, just add this above your method signature, so it looks something like this:

@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public void buton2(View view) throws SettingNotFoundException
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top