I put tiles on top of the map. There are areas where there are no tiles and I get a leak W/OkHttpClient: A connection to http://*****.***/ was leaked. Did you forget to close a response body?
. How to fix this error? I know about this solution, but I do not know the exact boundaries, so this method does not fit.
My code:
TileProvider tileProvider = new UrlTileProvider(256, 256) {
@Override
public URL getTileUrl(int x, int y, int zoom) {
String s = String.format("http://****.***/tiles/%d/%d/%d.png", zoom, x, y);
if (!checkTileExists(x, y, zoom)) {
return null;
}
try {
return new URL(s);
} catch (MalformedURLException e) {
throw new AssertionError(e);
}
}
private boolean checkTileExists(int x, int y, int zoom) {
int minZoom = 7;
int maxZoom = 17;
if ((zoom < minZoom || zoom > maxZoom)) {
return false;
}
return true;
}
};
tileOverlay = mMap.addTileOverlay(new TileOverlayOptions().tileProvider(tileProvider));