Reputation: 23
I'm new to android and trying to support as many versions as possible but I can't figure out how to get rid of the lint errors.
IE:
getDefaultDisplay().getSize(point); // is a API 13 function so I try
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2){
getDefaultDisplay().getSize(point); // now I need older functions for old versions
}else{
getDefaultDisplay().getHeight();
getDefaultDisplay().getWidth();
)
But I still have errors that getSize() is too high of an API, and that getWidth()/Height(), are deprecated.
Upvotes: 0
Views: 54
Reputation: 1903
If getSize is too high then just use the deprecated methods. They'll still work in higher API versions. There are only very specific cases when you shouldn't do that, like when using AlarmManager's set and setExact.
Upvotes: 0
Reputation: 1115
You need to provide the annotation on the method to let the IDE know you want to allow it for certain versions of android.
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
just before the method definition should do the trick
Upvotes: 1