Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can not access the GoogleMap instance at <code>doInBackground</code> method. The GoogleMap can only be read and modified from the main thread. Just the HTTP request shall be on background task. </p> <p>You need to modify <code>doInBackground</code> to return the list of coordinates and implement the GoogleMap update at <code>onPostExecute</code> method (at main thread).</p> <p>Here is the code based on Version 1.1:</p> <pre><code>GoogleMap googlemapa; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.buscarcontrincante); SupportMapFragment maps = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map); googlemapa = maps.getMap(); googlemapa.setMyLocationEnabled(true); googlemapa.setMapType(GoogleMap.MAP_TYPE_HYBRID); googlemapa.getUiSettings().setCompassEnabled(true); googlemapa.getUiSettings().setZoomControlsEnabled(true); googlemapa.getUiSettings().setAllGesturesEnabled(true); new RetreiveFeedTask().execute(); } class RetreiveFeedTask extends AsyncTask&lt;Void, Void, String[][]&gt; { @Override protected String[][] doInBackground(Void... args) { // Execute the HTTP request on background task Datos com = new Datos(); // File Datos.java return com.Ubic(); } @Override protected void onPostExecute(String[][] latlon) { double latitud; double longitud; String nombre; // Update the UI for (int i = 0; i &lt; latlon.length - 1; i++) { latitud = Double.parseDouble(latlon[i][0]); longitud = Double.parseDouble(latlon[i][3]); nombre = (latlon[i][2]); LatLng posicion = new LatLng(latitud, longitud); googlemapa.addMarker(new MarkerOptions().icon(BitmapDescriptorFactory.fromResource(R.drawable.icono_canchas)).position(posicion).title(nombre)); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload