Cannot resolve method checkSelfPermission

后端 未结 7 1071
南方客
南方客 2021-02-19 14:58

I\'m trying to make my app ready for Android 6 and now I\'m stuck to the point where you need to request and check permissions.

I tried the following from the docs:

7条回答
  •  我在风中等你
    2021-02-19 15:37

    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

提交回复
热议问题