GetlastknownLocation 在 LGE615 上返回 null,但它在 Galaxy Pocket 上运行良好,尽管两者都运行相同版本的 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();
}
}