1

Is it possible to get the Lat & Lng without going outdoor? My current situation is that user would have to be outdoor in order to get their location , in which also takes quite a long time for them to get one. I want my user to be able to get their location indoor.

DroidMatt
  • 183
  • 1
  • 4
  • 20
  • Why the user needs to be outdoor for getting their location? Is it due to network problem? – 0xC0DED00D Feb 21 '12 at 05:39
  • @Creator GPS only works well enough outdoors beacose it needs clear path to get data from satalites. When you are indoor there is roof and walls so the path is blocked and you can not get data from satalites. – J1and1 Aug 08 '12 at 09:01

4 Answers4

0

Yes, It is Possible, Inside the door you are getting your network. so you can use LocationManager.NETWORK_PROVIDER for getting the GPS Co-Ordinates.

Please look at to this answer.

Community
  • 1
  • 1
Lucifer
  • 29,392
  • 25
  • 90
  • 143
0

It depends on the GPS Provider you are using, and signal availabiliy to fix the location, I think you are using GPS provider only, so it is not working in door, try using network provider also in consideration.

Also, use Last known location, by the time gps fixes location, there is a good blog to fetch location at earliest.

android-developers.blogspot.in/2011/06/deep-dive-into-location.html

jeet
  • 29,001
  • 6
  • 52
  • 53
0

Yes it is possible , take hint from following code:

try {
            gps_enabled = locManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
        } catch (Exception ex) {
        }
        try {
            network_enabled = locManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
        } catch (Exception ex) {
        }

        if (!gps_enabled && !network_enabled) {
             // show alert 
        }
        if (network_enabled) {
            locManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locListener);
        }
        if (gps_enabled) {
            locManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locListener);
        }
0
    LocationManager locManager;   
    Location location;
 double lat;
 double lng;
    try {
                gps_enabled = locManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
            } catch (Exception ex) {
            }
            try {
                network_enabled = locManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
            } catch (Exception ex) {
            }

            if (!gps_enabled && !network_enabled) {
                 // show alert 
            }
            if (network_enabled) {
                  locManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);                
                locManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,1000,1, locationListener);
                location = locManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
             lat = location.getLatitude();
             lng = location.getLongitude();
            }
            if (gps_enabled) {
                locManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);              
                locManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,1000,1, locationListener);
                location = locManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
             lat = location.getLatitude();
             lng = location.getLongitude();
            }
vipin
  • 2,851
  • 4
  • 18
  • 32