You need to extend the UrlTileProvider class so you can define the URL for OSM tiled maps and add a tile overlay like that :
MyUrlTileProvider mTileProvider = new MyUrlTileProvider(256, 256, mUrl);
mMap.addTileOverlay(new TileOverlayOptions().tileProvider(mTileProvider));
With the url for OSM defined like that :
String mUrl = "http://a.tile.openstreetmap.org/{z}/{x}/{y}.png";
The MyUrlTileProvider class :
public class MyUrlTileProvider extends UrlTileProvider {
private String baseUrl;
public MyUrlTileProvider(int width, int height, String url) {
super(width, height);
this.baseUrl = url;
}
@Override
public URL getTileUrl(int x, int y, int zoom) {
try {
return new URL(baseUrl.replace("{z}", ""+zoom).replace("{x}",""+x).replace("{y}",""+y));
} catch (MalformedURLException e) {
e.printStackTrace();
}
return null;
}
}
I am now trying to get those tiled maps from OSM with an Offline Mode so if anyone get a quick solution, please let me know!