What's the difference between ActivityCompat and ContextCompat?

前端 未结 1 1882
情书的邮戳
情书的邮戳 2021-02-12 19:34

I\'m trying to use the Android camera, for API 23 or above, it requires asking for permission at runtime. According to the documentation, I can accomplish that using, ActivityCo

相关标签:
1条回答
  • 2021-02-12 19:56

    I don't understand what are the difference between the two and their trade-offs

    There's no trade-off really. Not sure why they wrote so - checkSelfPermission() is a method of ContextCompat and ActivityCompat is subclass (child) of ContextCompat so you can pass either one whenever object of ContextCompat class is required.

    Inheritance hierarchy (docs):

    0 讨论(0)
提交回复
热议问题