getlastknownlocation returns null in some devices

1k views Asked by At

GetlastknownLocation returns null on LGE615 but it works well on Galaxy Pocket although both run the same version of android

public void setLocation() {
    LM = (LocationManager) getApplicationContext().getSystemService(
            LOCATION_SERVICE);

    Criteria criteria = new Criteria();
           provider = LM.getBestProvider(criteria, false);
    try {
                    LM.requestLocationUpdates(provider, 1000, 1, this);
        if (LM != null) {
            Loc = LM.getLastKnownLocation(provider);

            if (Loc != null) {
                //Handle location
                                              }}


    } catch (Exception e) {
        e.printStackTrace();
    }

}
1

There are 1 answers

0
Andrew On

See this question for details. getLastKnownLocation may return null if last location is not known by the device. Probably it just take more time to initialize GPS on LGE615, than on Galaxy Pocket.