I have a class that extends Fragment and implements LocationListener.
When I write
LocationManager myLocalManager =
(LocationManager)getSystemService(Context.LOCATION_SERVICE);
I get an compile time error because the method getSystemService is not a method of Fragment.
What can I do in order to create the LocationManager?
inside your fragment simply call this:
So you simply get the Activity and call
getSystemService()from thereEdit:
As the
getActivitymethod is deprecated since API 28 you can just use: