Comments (7)
Emulator reports following error:
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.test/com.test.MainActivity}:
android.os.NetworkOnMainThreadException
Original comment by [email protected]
on 1 Sep 2012 at 6:34
- Added labels: ****
- Removed labels: ****
from osmbonuspack.
I just tried the Demo application with an Android 4.0.3 AVD
=> no crash, the app loads and display the road exactly as on previous Android
versions!
Very strange.
Could you download and try the OSMBonusPackDemo app on your emulator?
Could you tell which osmdroid and osmbonuspack versions you use?
And could you provide your source code?
Thanks
Original comment by [email protected]
on 1 Sep 2012 at 8:50
- Added labels: ****
- Removed labels: ****
from osmbonuspack.
osmdroid 3.0.8
osmbonuspack 2.1
Code:
package com.test.android;
import java.util.ArrayList;
import org.osmdroid.bonuspack.routing.OSRMRoadManager;
import org.osmdroid.bonuspack.routing.Road;
import org.osmdroid.bonuspack.routing.RoadManager;
import org.osmdroid.tileprovider.tilesource.TileSourceFactory;
import org.osmdroid.util.GeoPoint;
import org.osmdroid.views.MapController;
import org.osmdroid.views.MapView;
import org.osmdroid.views.overlay.PathOverlay;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class MainActivity extends Activity {
private MapView map;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
map = (MapView) findViewById(R.id.mapview);
map.setTileSource(TileSourceFactory.MAPNIK);
GeoPoint startPoint = new GeoPoint(48.13, -1.63);
MapController mapController = map.getController();
mapController.setCenter(startPoint);
mapController.setZoom(15);
RoadManager roadManager = new OSRMRoadManager();
ArrayList<GeoPoint> waypoints = new ArrayList<GeoPoint>();
waypoints.add(startPoint);
waypoints.add(new GeoPoint(48.4, -1.9)); //end point
Road road = roadManager.getRoad(waypoints);
PathOverlay roadOverlay = RoadManager.buildRoadOverlay(road, map.getContext());
map.getOverlays().add(roadOverlay);
map.invalidate();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
Original comment by [email protected]
on 1 Sep 2012 at 10:54
- Added labels: ****
- Removed labels: ****
from osmbonuspack.
Here is eclipse project:
http://ubuntuone.com/0KlvVfV2tQaVXBiPZTEb4S
Original comment by [email protected]
on 2 Sep 2012 at 5:08
- Added labels: ****
- Removed labels: ****
from osmbonuspack.
I found. Look at:
http://developer.android.com/reference/android/os/NetworkOnMainThreadException.h
tml
Basically, from SDK 3.0, we can't do network calls in the main thread.
I didn't got the issue on OSMBonusPackDemo because 1/ It targets an earlier SDK
version, and 2/ all network calls in the demo are done in threads (async
tasks).
You have 2 solutions:
- Give to your project a target SDK version earlier than 3.0 (even if the
emulator or phone used is > 3.0)
- Do the calls in threads => looking at the source code of the demo app could
help you.
I will add a note about that issue in the tutorials.
Original comment by [email protected]
on 2 Sep 2012 at 7:26
- Added labels: ****
- Removed labels: ****
from osmbonuspack.
Thank you for response
Original comment by [email protected]
on 2 Sep 2012 at 7:38
- Added labels: ****
- Removed labels: ****
from osmbonuspack.
Original comment by [email protected]
on 5 Sep 2012 at 7:23
- Changed state: Done
- Added labels: ****
- Removed labels: ****
from osmbonuspack.
Related Issues (20)
- Failed to resolve HOT 5
- Handle house numbers in GeocoderNominatim HOT 2
- KmlFeature's writeAsKml(...) does not export correct mId HOT 2
- Traffic updates HOT 2
- kml can't be load HOT 1
- App Crashes when using BingMapTiles offline HOT 1
- marker's onDoubleTap not working when adding the marker in RadiusMarkerClusterer
- Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0. HOT 1
- position marker following the route(polyline) like google maps HOT 6
- Failed to resolve: com.github.mkergall:osmbonuspack:6.9.0 [build Gradle warning] HOT 1
- GroundOverlay : bug in docs and need help with positioning by 1 point HOT 4
- OSRMRoadManager response (more data) and a small issue HOT 2
- RadiusMarkererCluster does infinite Zoom when Clicked HOT 1
- Avoid overlapping cluster HOT 3
- ANR with Marker Clustering HOT 2
- Improvement: adding interface instead of Marker in cluster
- How can i get near by places with 1000 meters radius?
- Nearest neighbor interpolation for GroundOverlay image?
- How to get MY_USER_AGENT
- RadiusMarkerClusterer
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from osmbonuspack.