Cannot resolve method checkSelfPermission

Here is how you need to call in various scenarios,

In case of activity:

 ContextCompat.checkSelfPermission(MyActivity.this,
        Manifest.permission.WRITE_CALENDAR);

In case of fragment:

 ContextCompat.checkSelfPermission(getActivity(),
        Manifest.permission.WRITE_CALENDAR);

In case of any utility class use context:

 ContextCompat.checkSelfPermission(context,
        Manifest.permission.WRITE_CALENDAR);

Comment below for further information


Oh my godness - what a stupid mistake.

AS imported the supportlib as a jar and this jar was from like 2014. I just replaced the jarimport with the real dependency and know it is working.

Thanks for your help guys!