1

Is it possible to change User Agent I send with every tile request in OSMDroid?

I'm currently getting 403 Forbidden error whenever I try to download a tile (as described in another SO question), probably because OSMDroid itself has been banned.

Community
  • 1
  • 1
syntagma
  • 23,346
  • 16
  • 78
  • 134
  • 1
    osmdroid hasn't been banned, just the (wrong) user-agent it supplies by default. Setting a *valid* user-agent is required by the [tile usage policy](http://wiki.openstreetmap.org/wiki/Tile_usage_policy). – scai Jan 19 '14 at 21:33

3 Answers3

2

Please follow Issue 515 to track this issue. We have implemented a fix and we will release a proper update soon. We will be providing a factory interface for customizing the user-agent.

kurtzmarc
  • 3,110
  • 1
  • 24
  • 40
1

It looks like the only way to specify the User Agent is to modify OSMDroid's MapTileDownloader.loadTile() method in the following way:

final HttpClient client = new DefaultHttpClient();
final HttpUriRequest head = new HttpGet(tileURLString);
head.setHeader("User-Agent", "OSMDroid"); // Add this line
final HttpResponse response = client.execute(head);

It solves the 403 Forbidden tile download problem.

syntagma
  • 23,346
  • 16
  • 78
  • 134
0

I had the same problem and I just downloaded the following jar file

https://oss.sonatype.org/content/groups/public/org/osmdroid/osmdroid-android/4.1/osmdroid-android-4.1.jar

It's the osmdroid-android-4.1.jar , put it in your /Libs project folder.

Rob Kielty
  • 7,958
  • 8
  • 39
  • 51
Marley
  • 1
  • 1