title: Get current location in a static context
body: <p>I'm just starting studying android.
  I have a Navigation Drawer Activity. I'm trying to get my current location. This is my code:</p>
  
  <pre><code>public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                   Bundle savedInstanceState) {
  
              View rootView=inflater.inflate(R.layout.fragment_main, container, false);
                  int sectionNumber = getArguments().getInt(ARG_SECTION_NUMBER);
                  switch (sectionNumber) {
                      case 1:
                          rootView = inflater.inflate(R.layout.fragment_monitor, container, false);
                          TextView lat = (TextView) rootView.findViewById(R.id.lat);
                          LocationManager locationmanager;
                          String context=Context.LOCATION_SERVICE;
                          locationmanager=(LocationManager) getSystemService(context);
                          String provider=LocationManager.NETWORK_PROVIDER;
                          Location location= locationmanager.getLastKnownLocation(provider);
  
                          double lat = location.getLatitude();
                          double lon = location.getLongitude();
  
                          break;
                      case 2:
                          rootView = inflater.inflate(R.layout.activity_mapa, container, false);
                          break;
                      case 3:
                          break;
                      default:
                          rootView = inflater.inflate(R.layout.fragment_main, container, false);
                  }
              return rootView;
          }
  </code></pre>
  
  <p>It has an error in getSystemService() method. It says that a non-static method cannot be referenced from a static context.</p>
  
  <p>Anyone knows how to solve this?</p>
  
  <p>thanks.</p>