I wrote most of an app just fine with min API level set to 7. I want to call a single API from level 8. Users with lower versions of android will survive without this \"extra fe
Would this one line be ignored?
No.
Would my app crash?
Spectactularly. :-)
Would the app be filtered by Google Play so they can't install?
No.
I'd like to have this single line ignore on lower devices.
You have two problems:
@SuppressLint("NewApi")
was the wrong quick-fix choice
You didn't add any code to avoid this line on older devices
Use @TargetApi(...)
instead of @SuppressLint("NewApi")
, where ...
is the name (e.g., FROYO
) or number (e.g., 8
) of the code that your method is referencing.
But before you do that, wrap your offending lines in a check to see if they should be executed on this device:
if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.FROYO) {
// then execute your code that requires API Level 8
}
// optional else block if you have some workaround for API Level 7
Your if
check will cause your line to be avoided. Your @TargetApi
annotation will cause Lint to stop yelling at you about referencing a too-new class or method.