Coder Social home page Coder Social logo

Android 4.0.3 about osmbonuspack HOT 7 CLOSED

mkergall avatar mkergall commented on August 22, 2024
Android 4.0.3

from osmbonuspack.

Comments (7)

GoogleCodeExporter avatar GoogleCodeExporter commented on August 22, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 22, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 22, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 22, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 22, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 22, 2024
Thank you for response 

Original comment by [email protected] on 2 Sep 2012 at 7:38

  • Added labels: ****
  • Removed labels: ****

from osmbonuspack.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 22, 2024

Original comment by [email protected] on 5 Sep 2012 at 7:23

  • Changed state: Done
  • Added labels: ****
  • Removed labels: ****

from osmbonuspack.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.