Sending GPS Coordinates via sms

只谈情不闲聊 提交于 2019-12-04 20:41:15

I think the problem is, location update is not done before you call the next Activity.

Before you get the updates, get the co-ordinates using one of the 3 providers. Refer following code.

private Location getUserLocation() {

location_manager = (LocationManager) getSystemService(LOCATION_SERVICE);
if (location_manager != null) {

   List<String > provider=location_manager .getAllProviders();
            Location location = null;
            for(int i=0;i<provider.size();i++){
                 location=location_manager .getLastKnownLocation(provider.get(i));
                 if(location!=null){
                          location_manager.requestLocationUpdates(provider.get(i),
                                                    MIN_TIME_BW_UPDATES,
                                                    MIN_DISTANCE_CHANGE_FOR_UPDATES,mlocListener);
                       break;
                      }
            }


return location;

}
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!