Skip to content Skip to sidebar Skip to footer

Cannot Resolve Getsystemservice In Fragment In Navigation Drawer

I'm trying to implement a navigation Drawer which has a Map in a Fragment. Here is my code. Here is the fragment_map.xml
LocationManagerlm= (LocationManager)getActivity().getSystemService(Context.LOCATION_SERVICE);

Solution 2:

you need to use

For Fragment:

getActivity().getSystemService() 

For Activity :

getSystemService() 

so for your code it will be

LocationManagerlm= (LocationManager)getActivity().getSystemService(Context.LOCATION_SERVICE);

Solution 3:

Use this

LocationManagerlm= LocationManager.getActivity().getSystemService(Context.LOCATION_SERVICE);

Post a Comment for "Cannot Resolve Getsystemservice In Fragment In Navigation Drawer"