gps - Is it possible to get callee location in android -
in android application want location of callee. when call him or want location of callee. there methods available caller location not callee location. want or location method. way it(if possible). or suggest workaround this. in advance.i getting location location manager follows.
//variables used in method location locationmanager locationmanager; // minimum distance change updates in meters private final long min_distance_change_for_updates = 10; // minimum time between updates in milliseconds private final long min_time_bw_updates = 1000; private boolean isgpsenabled = false; boolean cangetlocation = false; // flag network status boolean isnetworkenabled = false; private location location; // location private double latitude; // latitude private double longitude; // longitude //the method given below private void getlocation(){ locationmanager = (locationmanager) getsystemservice(location_service); if (locationmanager!=null && locationmanager.isproviderenabled(locationmanager.gps_provider)) { try { locationmanager = (locationmanager) getapplicationcontext() .getsystemservice(location_service); // getting gps status isgpsenabled = locationmanager .isproviderenabled(locationmanager.gps_provider); // getting network status isnetworkenabled = locationmanager .isproviderenabled(locationmanager.network_provider); if (!isgpsenabled && !isnetworkenabled) { // no network provider enabled } else { this.cangetlocation = true; // first location network provider if (isnetworkenabled) { locationmanager.requestlocationupdates( locationmanager.network_provider, min_time_bw_updates, min_distance_change_for_updates, this); log.d("network", "network"); if (locationmanager != null) { location = locationmanager .getlastknownlocation(locationmanager.network_provider); if (location != null) { latitude = location.getlatitude(); longitude = location.getlongitude(); } } } // if gps enabled lat/long using gps services if (isgpsenabled) { if (location == null) { locationmanager.requestlocationupdates( locationmanager.gps_provider, min_time_bw_updates, min_distance_change_for_updates, this); log.d("gps enabled", "gps enabled"); if (locationmanager != null) { location = locationmanager .getlastknownlocation(locationmanager.gps_provider); if (location != null) { latitude = location.getlatitude(); longitude = location.getlongitude(); } } } } } } catch (exception e) { e.printstacktrace(); } } }
Comments
Post a Comment