title: Android : Log does not show the current geolocation of device
body: <p>A simple code, to return current location in the log.
  I am using LocationManager and <code>LocationListener</code>. There seems to be no errors or exceptions. Program runs, except, the location isn't shown in the log</p>
  
  <p>Given below is the <code>MainActivity</code> code :</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
      private LocationManager locationManager;
      private LocationListener locationListener;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
          locationListener = new LocationListener() {
              @Override
              public void onLocationChanged(Location location) {
  
                  String longitude = String.valueOf(location.getLongitude());
                  String latitude = String.valueOf(location.getLatitude());
                  String loc = latitude + ", " + longitude;
                  Log.i("Location of phone",loc);
                  Toast.makeText(MainActivity.this, loc, Toast.LENGTH_SHORT).show();
  
              }
  
              @Override
              public void onStatusChanged(String provider, int status, Bundle extras) {
  
              }
  
              @Override
              public void onProviderEnabled(String provider) {
  
              }
  
              @Override
              public void onProviderDisabled(String provider) {
  
              }
          };
  
          if(ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED){
  
              //Ask for permission
              ActivityCompat.requestPermissions(this,new String[]{Manifest.permission.ACCESS_FINE_LOCATION},1);
  
          }
          else{
  
              locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 5000, 10, locationListener);
  
          }
  
      }
  
      @Override
      public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
          super.onRequestPermissionsResult(requestCode, permissions, grantResults);
  
          if(grantResults.length &gt; 0 &amp;&amp; grantResults[0] == PackageManager.PERMISSION_GRANTED){
  
              if(ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
  
                  locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 5000, 10, locationListener);
              }
          }
      }
  
  }
  </code></pre>
  
  <p><strong>Logcat:</strong></p>
  
  <pre><code>05-20 20:26:18.762 30871-30871/? E/Zygote: v2
  05-20 20:26:18.762 30871-30871/? I/libpersona: KNOX_SDCARD checking this for 10241
      KNOX_SDCARD not a persona
  05-20 20:26:18.763 30871-30871/? E/Zygote: accessInfo : 0
  05-20 20:26:18.764 30871-30871/? W/SELinux: SELinux selinux_android_compute_policy_index : Policy Index[2],  Con:u:r:zygote:s0 RAM:SEPF_SECMOBILE_7.0_0010, [-1 -1 -1 -1 0 1]
  05-20 20:26:18.766 30871-30871/? I/SELinux: SELinux: seapp_context_lookup: seinfo=untrusted, level=s0:c512,c768, pkgname=com.anurag.geolocationdemo 
  05-20 20:26:18.772 30871-30871/? I/art: Late-enabling -Xcheck:jni
  05-20 20:26:19.223 30871-30871/com.anurag.geolocationdemo I/InstantRun: starting instant run server: is main process
  05-20 20:26:19.382 30871-30871/com.anurag.geolocationdemo W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
  05-20 20:26:19.640 30871-30871/com.anurag.geolocationdemo D/TextView: setTypeface with style : 0
  05-20 20:26:19.643 30871-30871/com.anurag.geolocationdemo D/TextView: setTypeface with style : 0
  05-20 20:26:19.726 30871-30871/com.anurag.geolocationdemo D/TextView: setTypeface with style : 0
  05-20 20:26:19.872 30871-30871/com.anurag.geolocationdemo D/Choreographer: init sf_choreo_doframe   debug_Level : 0x4f4cdebug_game_running : false
  05-20 20:26:20.080 30871-30871/com.anurag.geolocationdemo D/ViewRootImpl@e453cae[MainActivity]: ThreadedRenderer.create() translucent=false
  05-20 20:26:20.108 30871-30871/com.anurag.geolocationdemo D/InputTransport: Input channel constructed: fd=71
  05-20 20:26:20.109 30871-30871/com.anurag.geolocationdemo D/ViewRootImpl@e453cae[MainActivity]: setView = DecorView@88c0a4f[MainActivity] touchMode=true
  05-20 20:26:20.132 30871-30871/com.anurag.geolocationdemo W/Activity: AppLock checkAppLockState locked:false verifying:false pkgName = com.anurag.geolocationdemo isInMultiWindowMode:false showWhenLocked:false
  05-20 20:26:20.134 30871-30871/com.anurag.geolocationdemo D/ViewRootImpl@e453cae[MainActivity]: dispatchAttachedToWindow
  05-20 20:26:20.171 30871-30871/com.anurag.geolocationdemo D/ViewRootImpl@e453cae[MainActivity]: Relayout returned: oldFrame=[0,0][0,0] newFrame=[0,0][720,1280] result=0x27 surface={isValid=true -307765248} surfaceGenerationChanged=true
      mHardwareRenderer.initialize() mSurface={isValid=true -307765248} hwInitialized=true
  05-20 20:26:20.259 30871-30871/com.anurag.geolocationdemo W/art: Before Android 4.1, method int android.support.v7.widget.DropDownListView.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView
  05-20 20:26:20.282 30871-30871/com.anurag.geolocationdemo D/ViewRootImpl@e453cae[MainActivity]: MSG_RESIZED_REPORT: frame=Rect(0, 0 - 720, 1280) ci=Rect(0, 48 - 0, 0) vi=Rect(0, 48 - 0, 0) or=1
  05-20 20:26:20.401 30871-30941/com.anurag.geolocationdemo I/OpenGLRenderer: Initialized EGL, version 1.4
  05-20 20:26:20.402 30871-30941/com.anurag.geolocationdemo D/OpenGLRenderer: Swap behavior 1
  05-20 20:26:20.416 30871-30941/com.anurag.geolocationdemo D/mali_winsys: EGLint new_window_surface(egl_winsys_display*, void*, EGLSurface, EGLConfig, egl_winsys_surface**, egl_color_buffer_format*, EGLBoolean) returns 0x3000,  [720x1280]-format:1
  05-20 20:26:38.324 30871-30871/com.anurag.geolocationdemo W/Activity: AppLock checkAppLockState locked:false verifying:false pkgName = com.anurag.geolocationdemo isInMultiWindowMode:false showWhenLocked:false
  05-20 20:26:38.904 30871-30871/com.anurag.geolocationdemo D/ViewRootImpl@e453cae[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 1
      mHardwareRenderer.initializeIfNeeded()#2 mSurface={isValid=true -307765248}
  05-20 20:26:38.911 30871-30871/com.anurag.geolocationdemo V/InputMethodManager: mNextServedView is change
  05-20 20:26:38.923 30871-30871/com.anurag.geolocationdemo V/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@81c3386 nm : com.anurag.geolocationdemo ic=null
  05-20 20:26:38.923 30871-30871/com.anurag.geolocationdemo I/InputMethodManager: [IMM] startInputInner - mService.startInputOrWindowGainedFocus
  05-20 20:26:38.966 30871-30885/com.anurag.geolocationdemo D/InputTransport: Input channel constructed: fd=82
  05-20 20:26:38.967 30871-30871/com.anurag.geolocationdemo V/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@b58f447 nm : com.anurag.geolocationdemo ic=null
  05-20 20:27:07.925 30871-30871/com.anurag.geolocationdemo V/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@8acd699 nm : com.anurag.geolocationdemo ic=null
  05-20 20:27:07.925 30871-30871/com.anurag.geolocationdemo I/InputMethodManager: [IMM] startInputInner - mService.startInputOrWindowGainedFocus
  05-20 20:27:07.929 30871-30871/com.anurag.geolocationdemo D/InputTransport: Input channel constructed: fd=84
      Input channel destroyed: fd=82
  05-20 20:27:13.339 30871-30871/com.anurag.geolocationdemo D/ViewRootImpl@e453cae[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 0
  </code></pre>
  
  <p><strong>AndroidManifest</strong>:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.anurag.geolocationdemo"&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:roundIcon="@mipmap/ic_launcher_round"
          android:supportsRtl="true"
          android:theme="@style/AppTheme"&gt;
          &lt;activity android:name=".MainActivity"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
      &lt;/application&gt;
  
      &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>As I said, there is no error that I can see.
  I'm running this on a device, Android 7.0, with location and high accuracy turned on.</p>
  
  <p>I'd be really obliged if you could tell where my error is.</p>