title: How to get GPS coordinates with run time permission for Android 6.0 Marshmallow?
body: <p>I tried setting up the gps permission for an andriod app using the below code in manifest.xml</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"&gt;&lt;/uses-permission&gt;
  </code></pre>
  
  <p>But when I execute I am not able to get the gps coordinates. I am getting "need permission" toast message. Need help. Here is my code snippet.</p>
  
  <pre><code>LocationManager locationManager = (LocationManager)
                  getSystemService(Context.LOCATION_SERVICE);
          LocationListener locationListener = new MyLocationListener();
          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) {
              Toast toast = Toast.makeText(getApplicationContext(), "no permission", Toast.LENGTH_LONG);
              toast.show();
              return;
          }
          locationManager.requestLocationUpdates(
                  LocationManager.GPS_PROVIDER, 5000, 10, locationListener);
  </code></pre>