0

I am trying to get a Android hash key for Facebook for my app using this code in my Utility.java class

enter image description here

but the getPackageManager() method is flagged, is it an import problem or am i missing something?

Szymon
  • 41,313
  • 16
  • 90
  • 109
Ojonugwa Jude Ochalifu
  • 23,935
  • 25
  • 104
  • 122

1 Answers1

1

getPackageManager() is a method of the Context class. I'm not completely sure where you have the code above but it seems to be in some sort of a helper class. You need to pass a Context context parameter to the method where your have this code defined and then change the line that uses getPackageManager() to

context.getPackageManager()...
Szymon
  • 41,313
  • 16
  • 90
  • 109
  • 1
    Yes it is in a helper class i created, and your suggestion removed the error although(due to the logic in my code) it didn't work.But i found from [link]http://stackoverflow.com/questions/5306009/facebook-android-generate-key-hash?rq=1 that the best way to generate a hash key from android code is to place the code above in the 'onCreate()' method, and run the application.Works like a charm from there. Thanks though. – Ojonugwa Jude Ochalifu Dec 08 '13 at 05:57