Code example for FragmentActivity

Methods: getSupportFragmentManager, getSystemService, onStart

        setup();	/** ---	IS THIS MY PROBLEM? onStart() vs. setup()?	---	*/ 
    protected void onStart() { 
        // Check if the GPS setting is currently enabled on the device. 
        // This verification should be done during onStart() because the system calls this method 
        // when the user returns to the activity, which ensures the desired location provider is 
        // enabled each time the activity resumes from the stopped state. 
        LocationManager locationManager =
                (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        final boolean gpsEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
        final boolean wifiEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
        if (!gpsEnabled && (mUseFine || !wifiEnabled)) {
            // Build an alert dialog here that requests that the user enable 
            // the location services, then when the user clicks the "OK" button, 
            // call enableLocationSettings() 
            new EnableGpsDialogFragment().show(getSupportFragmentManager(), "enableGpsDialog");