0

What is the use of @RequiresApi(Build.VERSION_CODES.M) when it is in front of a method?

I need it to call connectivityManager.activeNetwork

u-ways
  • 6,136
  • 5
  • 31
  • 47
ShadowHawwk
  • 29
  • 1
  • 3
  • 2
    Does this answer your question? [RequiresApi vs TargetApi android annotations](https://stackoverflow.com/questions/40007365/requiresapi-vs-targetapi-android-annotations) – denvercoder9 Nov 19 '20 at 10:13

1 Answers1

2

To be simple.
For connectivityManage.activeNetwork minimum required OS for an android is M i.e: Marshmallow.
Your app support lower version that marshmallow but while using connectivityManage.activeNetwork it will be needing Marshmallow for lower version it doesn't work
if end user has Marshmallow or next versions this code will be executed.