title: Get the Location without internet
body: <p>I try to get android current location without using internet and I create the  code in below but does not display any value in <code>TextView</code></p>
  
  <pre><code>package com.example.ahmed.gbs_location;
  
  import android.Manifest;
  import android.content.Context;
  import android.content.pm.PackageManager;
  import android.location.Location;
  import android.location.LocationListener;
  import android.location.LocationManager;
  import android.os.Bundle;
  import android.support.v4.app.ActivityCompat;
  import android.support.v7.app.AppCompatActivity;
  import android.widget.TextView;
  import android.widget.Toast;
  
  public class MainActivity extends AppCompatActivity implements LocationListener {
  TextView latitude;
  TextView longitude;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      latitude = (TextView) findViewById(R.id.tb1);
      longitude = (TextView) findViewById(R.id.tb2);
      LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
  
      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.makeText(MainActivity.this, "Ahmed", Toast.LENGTH_SHORT).show();
          return;
      }
      else
      locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
  }
  
  @Override
  public void onLocationChanged(Location location) {
      latitude.setText(String.valueOf(d));
      longitude.setText(String.valueOf( location.getLongitude()));
      latitude.setText(String.valueOf(( location.getLatitude())));
  }
  
  @Override
  public void onStatusChanged(String provider, int status, Bundle extras) {
  
  }
  
  @Override
  public void onProviderEnabled(String provider) {
  
  }
  
  @Override
  public void onProviderDisabled(String provider) {
  
  }
  
  }
  </code></pre>
  
  <p>In <code>AndroidManifest.xml</code> this code</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.example.ahmed.gbs_location"&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/&gt;
  
  &lt;application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      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;
  </code></pre>
  
  <p>I did not know why there are  value  for  latitude and   longitude  display  in <code>TextView</code>?</p>