Automatic Android OpenStreetMap Contributor
With FULL SOURCE
- Contribute to the openstreetmap-project within 4 lines of code

- Asynchronous upload to openstreetmap.org
- Generates tags automatically if non are supplied (like "[font=Courier New]September 2008[/font]")
This is how it looks like, having automatically contributed to the openstreetmap-project:


This is what the console will show on success:
DEBUG/OSMCONTRIBUTOR(413): Uploading 20080923_032525_418_YOURUSERNAME.gpx to
DEBUG/OSMCONTRIBUTOR(413): Destination Url: http://www.openstreetmap.org/api/0.5/gpx/create
DEBUG/OSMCONTRIBUTOR(413): Transferring data to server
DEBUG/OSMCONTRIBUTOR(413): return code: 200 OK
- A valid OpenStreetMap.org account. Enter it at [font=Courier New]OSMConstants.java[/font]
0. Download the package attached to this post and put files under "[font=Courier New]...srcorganddevopenstreetmapcontributorutil[/font]" to your desired package (adapt to new package-names)
1. Put this field to your GPS-Enabled Activity:
Using java Syntax Highlighting
- private RouteRecorder mRouteRecorder = new RouteRecorder();
Parsed in 0.030 seconds, using GeSHi 1.0.8.4
2. Add the following lines to the Implementation of your [font=Courier New]LocationListener.onLocationChanged(Location loc)[/font]:
Using java Syntax Highlighting
- public void onLocationChanged(Location loc) {
- if (loc != null)
- OSMContributor.this.mRouteRecorder.add(loc);
- }
Parsed in 0.030 seconds, using GeSHi 1.0.8.4
3. Modify the onDestroy() of your Activity, to make it similar to this one:
Using java Syntax Highlighting
- @Override
- protected void onDestroy() {
- super.onDestroy();
- // ...
- try {
- OSMUploader.uploadAsync(this.mRouteRecorder.getRecordedGeoPoints());
- } catch (IOException e) {
- Log.e(DEBUGTAG, "Error uploading route to openstreemaps.", e);
- }
- }
Parsed in 0.035 seconds, using GeSHi 1.0.8.4
Note: If you haven't already, you might have to add the following uses-permissions/library to your Manifest-File:
Using xml Syntax Highlighting
- <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
- <uses-permission android:name="android.permission.INTERNET" />
- <application android:icon="@drawable/icon" android:label="@string/app_name">
- <uses-library android:name="com.google.android.maps" />
Parsed in 0.001 seconds, using GeSHi 1.0.8.4
Thats it 

Regards,
plusminus




this is just great!!

