title: Android Marshmallow, locationManager.isProviderEnbled always return false
body: <pre><code>        locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
  
          //getting GPS status
          isGPSEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
          //getting network status
          isNetworkEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
  </code></pre>
  
  <p>Both are false, Although i did check for Marshmallow , there's something like runtime permissions, so i followed these links <a href="http://inthecheesefactory.com/blog/things-you-need-to-know-about-android-m-permission-developer-edition/en" rel="nofollow">link1</a> and <a href="http://developer.android.com/training/permissions/requesting.html" rel="nofollow">link2</a></p>
  
  <p>And did some debugging and putting <code>checkSelfPermission(android.Manifest.permission.ACCESS_FINE_LOCATION);</code> before isNetworkEnabled returns 0 , which is <code>PERMISSION_GRANTED</code> </p>
  
  <p><strong>Code</strong></p>
  
  <p>SplashScreenActivity</p>
  
  <pre><code>public class SplashScreenActivity extends Activity {
  
      private static final String TAG = "SplashScreenActivity";
      boolean isGPSEnabled = false;
  
      // flag for network status
      boolean isNetworkEnabled = false;
  
      final private int REQUEST_CODE_ASK_PERMISSIONS = 123;
  
      @TargetApi(Build.VERSION_CODES.M)
      @Override
      public void onCreate(Bundle icicle) {
          super.onCreate(icicle);
          setContentView(R.layout.activity_splashscreen);
  
          int hasLocationPermission = checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION);
          if (hasLocationPermission != PackageManager.PERMISSION_GRANTED) {
              requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
                      REQUEST_CODE_ASK_PERMISSIONS);
              return;
          }
          //comes till here . ie hasLocationPermission is true 
          LocationManager locationManager = (LocationManager) getApplicationContext().getSystemService(LOCATION_SERVICE);
  
          checkSelfPermission(android.Manifest.permission.ACCESS_FINE_LOCATION); //breakpoint at this line gives 0 ie PERMISSION_GRANTED
  
          isGPSEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); //false at debug breakpoint
          isNetworkEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);//false at debug breakpoint
  
      }
  
  
  }
  </code></pre>
  
  <p>Manifest <a href="http://pastebin.com/fHradFfa" rel="nofollow">Here</a></p>