How to store Build.Version Comparison in final boolean

+1 Dol Lod · August 28, 2015
final boolean check=Build.VERSION.SDK_INT<Build.VERSION_CODES.LOLLIPOP;
if(check)
 setSupportActionBar();
else
setActionBar();

This gives an error. I know the parameters aren't mentioned specifically, but they are android.support.v7.widget.Toolbar and android.widget.Toolbar accordingly as specified in layouts I created.

However, it complains that the API level may not be high enough.

Obviously I check the SDK version level and even store it in a final boolean for good form. Its value can't even be changed.

Why won't Android Studio accept this?

Post a Reply

Replies

Oldest  Newest  Rating
0 Dol Lod · August 31, 2015
Forget it. I have researched and there are too main ways to avoid this:

1) Surpress Lint.
2) Use Target(@API
  • 1

Java / Android Development

107,052 followers
About

Very popular language used to create desktop applications, website applets, and Android apps.

Links
Moderators
Bucky Roberts Administrator