except for the permissions that @AshishPedhadiya mentioned that you only listen to the GPS provider.
LocationListener locationListener = new MyLocationListener(); locationManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, 5000, 10, locationListener);
GPS does not work inside. Therefore, when you test your application, it almost always returns the location (0,0). You might also want to listen to NETWORK_PROVIDER, which, if there is no GPS location, estimates the location coming from cell towers and WiFi points.
locationManager.requestLocationUpdates( LocationManager.NETWORK_PROVIDER, 5000, 10, locationListener);
Also, to get a quick geographic location, check the Application.getLastKnownLocation() method.
source share