title: Location in Android 6.0.1 returns 0.0, but works in 4.0.1
body: <p>I've searched for solutions to this and tried the ones I could find that were pertinent, but still can't get this to work.  A specific section of code is not running.  The issue I'm having is that this all works on my old NEC Terrain (4.0.1, API 15), but will not work on my new Blackberry Priv (6.0.1, API 23).  In the newer phone, the first error log "Net enabled" shows up in logcat, and then none of the other error logs show up (I'm using them for troubleshooting).  In the old phone, everything works and all the logs show up.  What's stopping this code from running?  I added code for adding permissions, which I've posted below.  I also have the following in my manifest:</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt;
  &lt;uses-permission-sdk-23 android:name="android.permission.INTERNET" /&gt;
  &lt;uses-permission-sdk-23 android:name="android.permission.ACCESS_COARSE_LOCATION"/&gt;
  &lt;uses-permission-sdk-23 android:name="android.permission.ACCESS_FINE_LOCATION"/&gt;
  </code></pre>
  
  <p>Here's the declaration for locationManager:</p>
  
  <pre><code>locationManager = (LocationManager) context.getSystemService(LOCATION_SERVICE);
  </code></pre>
  
  <p>And here's the code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>if (isNetworkEnabled) {
                  Log.e("Tag", "Net Enabled");
  
                  if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED &amp;&amp; ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
                      Log.e("Tag", "No permission");
                  }
                  locationManager.requestLocationUpdates(
                          LocationManager.NETWORK_PROVIDER,
                          MIN_TIME_BW_UPDATES,
                          MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
  
                  if (locationManager == null) {
                      Log.e("Tag", "It's null.");
                  }
                  if (locationManager != null) {
                      location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
                      Log.e("Tag", "NetLocMan OK");
  
                      if (location != null) {
                          Log.e("Tag", "NetLoc OK");
                          latitude = location.getLatitude();
                          longitude = location.getLongitude();
                          Log.e("Tag", "" + latitude);
                          Log.e("Tag", "" + longitude);
                      }
                  }
  
              }
  
              if (isGPSEnabled) {
                  Log.e("Tag", "Location" + location);
                  if (location == null) {
                      Log.e("Tag", "GPSLoc finding");
                      locationManager.requestLocationUpdates(
                              LocationManager.GPS_PROVIDER,
                              MIN_TIME_BW_UPDATES,
                              MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
                      Log.e("Tag", "Location" + location);
  
                      if (locationManager != null) {
                          Log.e("Tag", "GPSLocMan OK");
                          location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
                          Log.e("Tag", "Location" + location);
  
                          if (location != null) {
                              latitude = location.getLatitude();
                              longitude = location.getLongitude();
                              Log.e("Tag", "" + latitude);
                              Log.e("Tag", "" + longitude);
                          }
                      }
                  }
              }</code></pre>
  </div>
  </div>
  </p>
  
  <p>This is the permissions code I'm using:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>private static final int PERMS_REQUEST_CODE = 123;
  
  if (!hasPermissions()){
              requestPerms();
          }
  
  private boolean hasPermissions(){
          int res = 0;
          //string array of permissions,
          String[] permissions = new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION};
  
          for (String perms : permissions){
              res = checkCallingOrSelfPermission(perms);
              if (!(res == PackageManager.PERMISSION_GRANTED)){
                  return false;
              }
          }
          return true;
      }
  
  @Override
      public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
          boolean allowed = true;
  
          switch (requestCode){
              case PERMS_REQUEST_CODE:
  
                  for (int res : grantResults){
                      // if user granted all permissions.
                      allowed = allowed &amp;&amp; (res == PackageManager.PERMISSION_GRANTED);
                  }
  
                  break;
              default:
                  // if user not granted permissions.
                  allowed = false;
                  break;
          }
  
          if (allowed){
              //user granted all permissions we can perform our task.
  
          }
          else {
              // we will give warning to user that they haven't granted permissions.
              if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.M) {
                  if (shouldShowRequestPermissionRationale(Manifest.permission.ACCESS_FINE_LOCATION)){
                      Toast.makeText(this, "Permissions denied.\nCannot continue.", Toast.LENGTH_SHORT).show();
                  }
                  if (shouldShowRequestPermissionRationale(Manifest.permission.ACCESS_COARSE_LOCATION)){
                      Toast.makeText(this, "Permissions denied.\nCannot continue.", Toast.LENGTH_SHORT).show();
                  }
              }
          }
  
      }</code></pre>
  </div>
  </div>
  </p>
  
  <p>Thanks for any help!  Please let me know if you need more code.</p>