private String sessionId;
public void initService(Ads adsComponent) {
if (getLocation() == null) {
LocationManager lm = LocationManager.getLocationManager();
Location loc;
if (lm.getStatus() == LocationManager.AVAILABLE) {
try {
loc = lm.getCurrentLocation();
} catch (IOException e) {
Log.e(e);
loc = lm.getLastKnownLocation();
}
} else {
loc = lm.getLastKnownLocation();
}
// Use location if provided, otherwise use either reverse IP or
// Geocode depending on availability of sensor.
if (adsComponent.getLocation() != null) {
LookupLocation lloc = new LookupLocation();
parseLocation(lloc, loc, adsComponent.getLocation());
setLocation(lloc);
} else {
if (loc == null) {
LocationLookupService lookup = LocationLookupService.createLookupByIP();
LookupLocation lloc = lookup.getLocation(new IPAddress(null));
if (lloc.getLookupStatus() == LookupLocation.STATUS_OK) {
setLocation(lloc);
}
} else {
LocationLookupService lookup = LocationLookupService.createLookupByGeocode();
LookupLocation lloc = lookup.getLocation(new Coordinate(loc));
if (lloc.getLookupStatus() != LookupLocation.STATUS_OK) {
lloc.setLatitude(loc.getLatitude());
lloc.setLongtitude(loc.getLongtitude());
}
}
}
}
setPost(false);