1

I have this problem, I cant understand why this line of code must to be written like this

enter image description here

What does "PackageManager" stand for?

Frank
  • 66,179
  • 8
  • 96
  • 180
N.JB
  • 51
  • 1
  • 4

1 Answers1

0
public abstract class PackageManager

Class for retrieving various kinds of information related to the application packages that are currently installed on the device.

Source

fida1989
  • 3,234
  • 1
  • 27
  • 30
  • Thanks for your answer, but i dont understand whats the logic, why PERMISSION_GRANTED is linked up with PackageManager as PERMISSION_GRANTED is not a package. – N.JB Sep 19 '17 at 17:37
  • It's a constant defined in `PackageManager` class. As `PackageManager` is a *Class for retrieving **various kinds of information** related to the application packages*, it also allows querying for permissions granted to a certain package. If you open the source code to `ContextCompat.chekSelfPermission` you'll see that it's just a shortcut to `PackageManager.checkPermission`. So the real question is "why ContextCompat.checkSelfPermission"? And the answer is: the keyword is "self". – Eugen Pechanec Sep 19 '17 at 17:41