Autore Topic: Parsing errato in importazione coordinate da xml  (Letto 712 volte)

Offline darkmax

  • Utente junior
  • **
  • Post: 62
  • Respect: 0
    • Mostra profilo
    • Emoe - Agenzia di comunicazione Torino
  • Dispositivo Android:
    Samsung Galaxy S 3
  • Sistema operativo:
    Mac OS X
Parsing errato in importazione coordinate da xml
« il: 19 Gennaio 2012, 01:05:42 CET »
0
Ciao a tutti,
per me è il primo post. Quindi un saluto a tutti.
Mi sto avvicinando ad Android e sto creando la mia prima applicazione.. Devo importare delle coordinate da un file xml online per poi disegnare dei pinpoint su di una google map.

Ecco il file xml:

Codice: [Seleziona]
<td:traffic_data xmlns:td="http://www.prova.it" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.prova.it/traffic_data
http://www.prova.it" generation_time="2012-01-16T10:41:33+01:00" start_time="2012-01-16T10:36:33+01:00" end_time="2012-01-16T10:41:33+01:00" source="prova.IT">
<td:location_reference>
<td:tmc_info tabcd="1" cid="25"/>
</td:location_reference>
<td:PK_data Name="Prova1" ID="1" status="1" Total="134" Free="83" tendence="-1" lat="45.07243" lng="7.67480"/>
<td:PK_data Name="Prova2" ID="46" status="1" Total="305" Free="1" tendence="-1" lat="45.03660" lng="7.67249"/>
<td:PK_data Name="Prova3" ID="2" status="1" Total="434" lat="45.06355" lng="7.68357"/>
<td:PK_data Name="Prova4" ID="3" status="1" Total="858" lat="45.07248" lng="7.66716"/>
</td:traffic_data>

Ed ecco le classi:

classe AsynTask

Codice: [Seleziona]
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.OverlayItem;

import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.util.Log;

public class MyAsynTask extends AsyncTask<Context, Integer, String> {
       
        private Context myContext = null;

        /*
        public MyAsynTask(Context context) {
                this.myContext = context;
                // TODO Auto-generated constructor stub
        }
        */
        private final String MY_DEBUG_TAG = "Prova";
        private final String LIST_TAG = "Lista";
        private ArrayList<ParsedExampleDataSet> list = new ArrayList<ParsedExampleDataSet>();

        @Override
        protected String doInBackground(Context... params) {
               
        try {
                /* Create a URL we want to load some xml-data from. */
                URL url = new URL("http://opendata.5t.torino.it/get_pk");
                myContext = params[0];

                /* Get a SAXParser from the SAXPArserFactory. */
                SAXParserFactory spf = SAXParserFactory.newInstance();
                SAXParser sp = spf.newSAXParser();

                /* Get the XMLReader of the SAXParser we created. */
                XMLReader xr = sp.getXMLReader();
                /* Create a new ContentHandler and apply it to the XML-Reader*/
                ExampleHandler myExampleHandler = new ExampleHandler();
                xr.setContentHandler(myExampleHandler);
               
                /* Parse the xml-data from our URL. */
                xr.parse(new InputSource(url.openStream()));
                /* Parsing has finished. */
                 
                list = myExampleHandler.getParsedData();
                               
        } catch (Exception e) {
                /* Display any Error to the GUI. */
                Log.e(MY_DEBUG_TAG, "QueryError", e);
        }
       

               
                return "123";
        }
        @Override
        protected void onPostExecute(String result) {
                // TODO Auto-generated method stub
                super.onPostExecute(result);
                Activity activity=(Activity)myContext;
                MapView m = (MapView) activity.findViewById(R.id.mvMain);
                Drawable d = activity.getResources().getDrawable(R.drawable.parking);
               
                Log.d(LIST_TAG , ""+ list.size());
               
                int x = (int)(7.234564*1E6);
                int y = (int)(7.234564*1E6);
                GeoPoint touchedPoint = m.getProjection().fromPixels(x, y);
               
                OverlayItem overlayItem = new OverlayItem(touchedPoint, "Prova", "Stringa");
                CustomPinPoint custom = new CustomPinPoint(d, activity);
                custom.insertPinpoint(overlayItem);
                List<Overlay> overlayList = m.getOverlays();
                overlayList.add(custom);
               
       
               
               
               
        }

classe ExampleHandler:

Codice: [Seleziona]
import java.util.ArrayList;

import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
 
 
public class ExampleHandler extends DefaultHandler{
 
        // ===========================================================
        // Fields
        // ===========================================================
       
        private boolean in_traffic_data = false;
        private boolean in_location_reference = false;
        private boolean in_PK_data = false;
       
        private ParsedExampleDataSet myParsedExampleDataSet;
        private ArrayList<ParsedExampleDataSet> parsedElements = new ArrayList<ParsedExampleDataSet>();
 
        // ===========================================================
        // Getter & Setter
        // ===========================================================
 
        public ArrayList<ParsedExampleDataSet> getParsedData() {
                return this.parsedElements;
        }
 
        // ===========================================================
        // Methods
        // ===========================================================
        @Override
        public void startDocument() throws SAXException {
                //this.myParsedExampleDataSet = new ParsedExampleDataSet();
        }
 
        @Override
        public void endDocument() throws SAXException {
                // Nothing to do
        }
 
        @Override
        public void startElement(String namespaceURI, String localName,
                        String qName, Attributes atts) throws SAXException {
                if (localName.equals("traffic_data")) {
                        this.in_traffic_data = true;
                }else if (localName.equals("location_reference")) {
                        this.in_location_reference = true;
                }else if (localName.equals("PK_data")) {
                        String name = atts.getValue("Name");
                        String totalValue = atts.getValue("Total");
                        int total = Integer.parseInt(totalValue);
                        String totalFree = atts.getValue("Free");
                        int free = Integer.parseInt(totalFree);
                        String latitude = atts.getValue("lat");
                        double lat = Double.parseDouble(latitude);
                        String longitude = atts.getValue("lng");
                        double lng = Double.parseDouble(longitude);
                       
                        myParsedExampleDataSet = new ParsedExampleDataSet(name,total,free,lat,lng);
                       
                        parsedElements.add(myParsedExampleDataSet);
                       
                }
        }
       
        /** Gets be called on closing tags like:
         * </tag> */
        @Override
        public void endElement(String namespaceURI, String localName, String qName)
                        throws SAXException {
                if (localName.equals("traffic_data")) {
                        this.in_traffic_data = false;
                }else if (localName.equals("location_reference")) {
                        this.in_location_reference = false;
                }else if (localName.equals("PK_data")) {
                        this.in_PK_data = false;
                }
        }
       
        /** Gets be called on the following structure:
         * <tag>characters</tag> */
        @Override
    public void characters(char ch[], int start, int length) {
                if(this.in_PK_data){
                myParsedExampleDataSet.setExtractedName(new String(ch, start, length));
        }
    }

classe ParsedExampleDataSet:

Codice: [Seleziona]
public class ParsedExampleDataSet {
        private String extractedName = null;
        private int extractedFree = 0;
        private int extractedTotal = 0;
        private double extractedLat = 0.0;
        private double extractedLng = 0.0;
       
       
 
        public ParsedExampleDataSet(String extractedName, int extractedFree,
                                int extractedTotal, double extractedLat, double extractedLng) {
                        super();
                        this.extractedName = extractedName;
                        this.extractedFree = extractedFree;
                        this.extractedTotal = extractedTotal;
                        this.extractedLat = extractedLat;
                        this.extractedLng = extractedLng;
                }
                public double getExtractedLat() {
                        return extractedLat;
                }
                public void setExtractedLat(double extractedLat) {
                        this.extractedLat = extractedLat;
                }
                public double getExtractedLng() {
                        return extractedLng;
                }
                public void setExtractedLng(double extractedLng) {
                        this.extractedLng = extractedLng;
                }
                public String getExtractedName() {
                return extractedName;
        }
        public void setExtractedName(String extractedName) {
                this.extractedName = extractedName;
        }
 
        public int getExtractedFree() {
                return extractedFree;
        }
        public void setExtractedFree(int extractedFree) {
                this.extractedFree = extractedFree;
        }
       
        public int getExtractedTotal() {
                    return extractedTotal;
        }
        public void setExtractedTotal(int extractedTotal) {
                    this.extractedTotal = extractedTotal;
        }
                @Override
                public String toString() {
                        return "ParsedExampleDataSet [extractedName=" + extractedName
                                        + ", extractedFree=" + extractedFree + ", extractedTotal="
                                        + extractedTotal + ", extractedLat=" + extractedLat
                                        + ", extractedLng=" + extractedLng + "]";
                }
       

ed ecco il logcat:

Codice: [Seleziona]
01-19 00:02:26.995: E/QemuSensors(308): data__poll: len=-1, errno=9: Bad file number
01-19 00:02:27.005: E/QemuSensors(308): data__poll: len=-1, errno=9: Bad file number
01-19 00:02:30.425: E/Prova(308): QueryError
01-19 00:02:30.425: E/Prova(308): java.lang.NumberFormatException: unable to parse 'null' as integer
01-19 00:02:30.425: E/Prova(308):         at java.lang.Integer.parseInt(Integer.java:406)
01-19 00:02:30.425: E/Prova(308):         at java.lang.Integer.parseInt(Integer.java:382)
01-19 00:02:30.425: E/Prova(308):         at it.program.max.ExampleHandler.startElement(ExampleHandler.java:56)
01-19 00:02:30.425: E/Prova(308):         at org.apache.harmony.xml.ExpatParser.startElement(ExpatParser.java:146)
01-19 00:02:30.425: E/Prova(308):         at org.apache.harmony.xml.ExpatParser.append(Native Method)
01-19 00:02:30.425: E/Prova(308):         at org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:521)
01-19 00:02:30.425: E/Prova(308):         at org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:482)
01-19 00:02:30.425: E/Prova(308):         at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:320)
01-19 00:02:30.425: E/Prova(308):         at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:277)
01-19 00:02:30.425: E/Prova(308):         at it.program.max.MyAsynTask.doInBackground(MyAsynTask.java:58)
01-19 00:02:30.425: E/Prova(308):         at it.program.max.MyAsynTask.doInBackground(MyAsynTask.java:1)
01-19 00:02:30.425: E/Prova(308):         at android.os.AsyncTask$2.call(AsyncTask.java:185)
01-19 00:02:30.425: E/Prova(308):         at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
01-19 00:02:30.425: E/Prova(308):         at java.util.concurrent.FutureTask.run(FutureTask.java:137)
01-19 00:02:30.425: E/Prova(308):         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
01-19 00:02:30.425: E/Prova(308):         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
01-19 00:02:30.425: E/Prova(308):         at java.lang.Thread.run(Thread.java:1096)
01-19 00:02:32.595: D/dalvikvm(308): threadid=9: still suspended after undo (sc=1 dc=1 s=Y)
01-19 00:02:32.595: D/dalvikvm(308): GC_EXPLICIT freed 646 objects / 78720 bytes in 161ms
01-19 00:02:36.618: D/dalvikvm(308): threadid=9: still suspended after undo (sc=1 dc=1 s=Y)
01-19 00:02:36.625: D/dalvikvm(308): GC_EXPLICIT freed 200 objects / 44016 bytes in 159ms
01-19 00:02:40.525: D/dalvikvm(308): threadid=9: still suspended after undo (sc=1 dc=1 s=Y)
01-19 00:02:40.536: D/dalvikvm(308): GC_EXPLICIT freed 207 objects / 44480 bytes in 173ms
01-19 00:02:45.187: D/dalvikvm(308): threadid=9: still suspended after undo (sc=1 dc=1 s=Y)
01-19 00:02:45.215: D/dalvikvm(308): GC_EXPLICIT freed 218 objects / 43880 bytes in 300ms
01-19 00:02:51.755: D/dalvikvm(308): threadid=9: still suspended after undo (sc=1 dc=1 s=Y)
01-19 00:02:51.807: D/dalvikvm(308): GC_EXPLICIT freed 299 objects / 46744 bytes in 230ms
01-19 00:02:58.135: D/dalvikvm(308): threadid=9: still suspended after undo (sc=1 dc=1 s=Y)
01-19 00:02:58.148: D/dalvikvm(308): GC_EXPLICIT freed 271 objects / 45168 bytes in 155ms
01-19 00:03:02.265: D/dalvikvm(308): threadid=9: still suspended after undo (sc=1 dc=1 s=Y)
01-19 00:03:02.286: D/dalvikvm(308): GC_EXPLICIT freed 194 objects / 42504 bytes in 251ms
01-19 00:03:08.456: D/dalvikvm(308): threadid=9: still suspended after undo (sc=1 dc=1 s=Y)
01-19 00:03:08.486: D/dalvikvm(308): GC_EXPLICIT freed 249 objects / 43872 bytes in 279ms
01-19 00:03:13.975: D/dalvikvm(308): threadid=9: still suspended after undo (sc=1 dc=1 s=Y)
01-19 00:03:13.995: D/dalvikvm(308): GC_EXPLICIT freed 243 objects / 45336 bytes in 252ms


Purtroppo dal debug l'applicazione si ferma sul parse.. Non ho postato solo l'activity che fa partire l'applicazione

Offline teskio

  • Moderatore globale
  • Utente normale
  • *****
  • Post: 387
  • Respect: +118
    • Github
    • Google+
    • Mostra profilo
    • Skullab
  • Dispositivo Android:
    Cubot GT99 / SurfTab Ventos 10.1
  • Play Store ID:
    Skullab Software
  • Sistema operativo:
    windows 7 / ubuntu 12.04
Re:Parsing errato in importazione coordinate da xml
« Risposta #1 il: 19 Gennaio 2012, 08:09:53 CET »
0
Bhè il logcat è chiaro : java.lang.NumberFormatException: unable to parse 'null' as integer
generato dalla riga 56 del file ExampleHandler.java

Ti conviene fare o un controllo preliminare prima di parsare oppure usare il blocco try/catch e gestire le eccezioni di conseguenza :-)
e infine...Benvenuto !

Offline bradipao

  • Moderatore globale
  • Utente storico
  • *****
  • Post: 4043
  • keep it simple
  • Respect: +567
    • Github
    • Google+
    • bradipao
    • Mostra profilo
  • Dispositivo Android:
    Nexus 5
  • Play Store ID:
    Bradipao
  • Sistema operativo:
    W7
Re:Parsing errato in importazione coordinate da xml
« Risposta #2 il: 19 Gennaio 2012, 08:37:50 CET »
0
Come dice teskio, per fortuna la causa è evidente dal LogCat: stai cercando di fare parsing di qualcosa che è null.

Più in particolare, sono questo genere di righe che creano problemi:
Codice (Java): [Seleziona]
String totalValue = atts.getValue("Total");
int total = Integer.parseInt(totalValue);

Appaiono innocue e perfettamente valide, spesso funzionano anche benissimo, ma contengono un problema devastante. Se l'attributo Total non esiste, getValue ti ritorna NULL e l'applicazione crasha. Anche se hai la certezza che l'attributo Total ci sarà sempre, merita sempre scrivere una cosa di questo tipo.

Codice (Java): [Seleziona]
String totalValue = atts.getValue("Total");
if (totalValue!=null) total = Integer.parseInt(totalValue);
else { // decidi tu come risolvere il caso anomalo dell'assenza di attributo, eventualmente con un deafult }
NON rispondo a domande nei messaggi privati
Bradipao @ Play Store

Offline darkmax

  • Utente junior
  • **
  • Post: 62
  • Respect: 0
    • Mostra profilo
    • Emoe - Agenzia di comunicazione Torino
  • Dispositivo Android:
    Samsung Galaxy S 3
  • Sistema operativo:
    Mac OS X
Re:Parsing errato in importazione coordinate da xml
« Risposta #3 il: 19 Gennaio 2012, 10:01:39 CET »
0
Ciao e grazie a tutti.

In effetti ho provato a modificare come mi avete detto(if totalFree != null) ...

e non si blocca più in quel punto. Il problema è che ora il logcat mi da questo:

Codice: [Seleziona]
01-19 08:54:55.612: W/ActivityThread(309): Application it.program.max is waiting for the debugger on port 8100...
01-19 08:54:55.642: I/System.out(309): Sending WAIT chunk
01-19 08:54:55.842: I/dalvikvm(309): Debugger is active
01-19 08:54:55.842: I/System.out(309): Debugger has connected
01-19 08:54:55.842: I/System.out(309): waiting for debugger to settle...
01-19 08:54:56.052: I/System.out(309): waiting for debugger to settle...
01-19 08:54:56.252: I/System.out(309): waiting for debugger to settle...
01-19 08:54:56.452: I/System.out(309): waiting for debugger to settle...
01-19 08:54:56.662: I/System.out(309): waiting for debugger to settle...
01-19 08:54:56.862: I/System.out(309): waiting for debugger to settle...
01-19 08:54:57.062: I/System.out(309): waiting for debugger to settle...
01-19 08:54:57.326: I/System.out(309): waiting for debugger to settle...
01-19 08:54:57.541: I/System.out(309): waiting for debugger to settle...
01-19 08:54:57.752: I/System.out(309): waiting for debugger to settle...
01-19 08:54:57.986: I/System.out(309): waiting for debugger to settle...
01-19 08:54:58.200: I/System.out(309): waiting for debugger to settle...
01-19 08:54:58.413: I/System.out(309): debugger has settled (1455)
01-19 08:55:06.162: D/dalvikvm(309): GC_FOR_MALLOC freed 4646 objects / 288096 bytes in 75ms
01-19 08:55:08.443: D/dalvikvm(309): GC_FOR_MALLOC freed 10469 objects / 636112 bytes in 59ms
01-19 08:55:10.263: D/dalvikvm(309): GC_FOR_MALLOC freed 4973 objects / 325104 bytes in 59ms
01-19 08:55:12.483: D/dalvikvm(309): GC_FOR_MALLOC freed 6579 objects / 401288 bytes in 61ms
01-19 08:55:14.284: D/dalvikvm(309): GC_FOR_MALLOC freed 8045 objects / 621400 bytes in 66ms
01-19 08:55:16.383: D/dalvikvm(309): GC_FOR_MALLOC freed 6078 objects / 370136 bytes in 62ms
01-19 08:55:17.733: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 08:55:17.733: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 08:55:17.933: I/MapActivity(309): Handling network change notification:CONNECTED
01-19 08:55:17.933: E/MapActivity(309): Couldn't get connection factory client
01-19 08:55:18.123: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 08:55:18.293: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 08:55:18.593: D/dalvikvm(309): threadid=9: still suspended after undo (sc=1 dc=1 s=Y)
01-19 08:55:18.603: D/dalvikvm(309): GC_EXTERNAL_ALLOC freed 3657 objects / 315720 bytes in 63ms
01-19 08:55:18.863: D/dalvikvm(309): threadid=9: still suspended after undo (sc=1 dc=1 s=Y)
01-19 08:55:18.873: D/dalvikvm(309): GC_FOR_MALLOC freed 218 objects / 54816 bytes in 60ms
01-19 08:55:19.093: D/dalvikvm(309): threadid=9: still suspended after undo (sc=1 dc=1 s=Y)
01-19 08:55:19.093: D/dalvikvm(309): GC_FOR_MALLOC freed 140 objects / 65616 bytes in 59ms
01-19 08:55:19.224: D/dalvikvm(309): threadid=9: still suspended after undo (sc=1 dc=1 s=Y)
01-19 08:55:19.233: D/dalvikvm(309): GC_FOR_MALLOC freed 2701 objects / 161168 bytes in 58ms
01-19 08:55:19.403: D/dalvikvm(309): threadid=9: still suspended after undo (sc=1 dc=1 s=Y)
01-19 08:55:19.403: D/dalvikvm(309): GC_FOR_MALLOC freed 103 objects / 57120 bytes in 60ms
01-19 08:55:19.562: D/dalvikvm(309): threadid=9: still suspended after undo (sc=1 dc=1 s=Y)
01-19 08:55:19.562: D/dalvikvm(309): GC_EXTERNAL_ALLOC freed 84 objects / 60576 bytes in 58ms
01-19 08:55:20.932: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 08:55:20.932: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 08:55:20.942: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 08:55:22.832: D/dalvikvm(309): threadid=9: still suspended after undo (sc=1 dc=1 s=Y)
01-19 08:55:22.872: D/dalvikvm(309): GC_FOR_MALLOC freed 1773 objects / 124464 bytes in 112ms
01-19 08:55:23.282: D/dalvikvm(309): threadid=9: still suspended after undo (sc=1 dc=1 s=Y)
01-19 08:55:23.282: D/dalvikvm(309): GC_EXTERNAL_ALLOC freed 3640 objects / 214648 bytes in 59ms
01-19 08:55:26.492: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 08:55:26.492: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 08:55:26.502: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 08:55:26.502: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 08:55:26.612: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 08:55:50.372: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 08:57:40.116: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number


Offline bradipao

  • Moderatore globale
  • Utente storico
  • *****
  • Post: 4043
  • keep it simple
  • Respect: +567
    • Github
    • Google+
    • bradipao
    • Mostra profilo
  • Dispositivo Android:
    Nexus 5
  • Play Store ID:
    Bradipao
  • Sistema operativo:
    W7
Re:Parsing errato in importazione coordinate da xml
« Risposta #4 il: 19 Gennaio 2012, 10:22:14 CET »
0
che intendi di preciso? se non esce l'app funziona? o ci sono errori logici?
NON rispondo a domande nei messaggi privati
Bradipao @ Play Store

Offline darkmax

  • Utente junior
  • **
  • Post: 62
  • Respect: 0
    • Mostra profilo
    • Emoe - Agenzia di comunicazione Torino
  • Dispositivo Android:
    Samsung Galaxy S 3
  • Sistema operativo:
    Mac OS X
Re:Parsing errato in importazione coordinate da xml
« Risposta #5 il: 19 Gennaio 2012, 10:27:44 CET »
0
Nel senso che ho lanciato il debug e il logacat mi da questo errore:

Codice: [Seleziona]
01-19 08:54:55.612: W/ActivityThread(309): Application it.program.max is waiting for the debugger on port 8100...
01-19 08:54:55.642: I/System.out(309): Sending WAIT chunk
01-19 08:54:55.842: I/dalvikvm(309): Debugger is active
01-19 08:54:55.842: I/System.out(309): Debugger has connected
01-19 08:54:55.842: I/System.out(309): waiting for debugger to settle...
01-19 08:54:56.052: I/System.out(309): waiting for debugger to settle...
01-19 08:54:56.252: I/System.out(309): waiting for debugger to settle...
01-19 08:54:56.452: I/System.out(309): waiting for debugger to settle...
01-19 08:54:56.662: I/System.out(309): waiting for debugger to settle...
01-19 08:54:56.862: I/System.out(309): waiting for debugger to settle...
01-19 08:54:57.062: I/System.out(309): waiting for debugger to settle...
01-19 08:54:57.326: I/System.out(309): waiting for debugger to settle...
01-19 08:54:57.541: I/System.out(309): waiting for debugger to settle...
01-19 08:54:57.752: I/System.out(309): waiting for debugger to settle...
01-19 08:54:57.986: I/System.out(309): waiting for debugger to settle...
01-19 08:54:58.200: I/System.out(309): waiting for debugger to settle...
01-19 08:54:58.413: I/System.out(309): debugger has settled (1455)
01-19 08:55:06.162: D/dalvikvm(309): GC_FOR_MALLOC freed 4646 objects / 288096 bytes in 75ms
01-19 08:55:08.443: D/dalvikvm(309): GC_FOR_MALLOC freed 10469 objects / 636112 bytes in 59ms
01-19 08:55:10.263: D/dalvikvm(309): GC_FOR_MALLOC freed 4973 objects / 325104 bytes in 59ms
01-19 08:55:12.483: D/dalvikvm(309): GC_FOR_MALLOC freed 6579 objects / 401288 bytes in 61ms
01-19 08:55:14.284: D/dalvikvm(309): GC_FOR_MALLOC freed 8045 objects / 621400 bytes in 66ms
01-19 08:55:16.383: D/dalvikvm(309): GC_FOR_MALLOC freed 6078 objects / 370136 bytes in 62ms
01-19 08:55:17.733: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 08:55:17.733: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 08:55:17.933: I/MapActivity(309): Handling network change notification:CONNECTED
01-19 08:55:17.933: E/MapActivity(309): Couldn't get connection factory client
01-19 08:55:18.123: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 08:55:18.293: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 08:55:18.593: D/dalvikvm(309): threadid=9: still suspended after undo (sc=1 dc=1 s=Y)
01-19 08:55:18.603: D/dalvikvm(309): GC_EXTERNAL_ALLOC freed 3657 objects / 315720 bytes in 63ms
01-19 08:55:18.863: D/dalvikvm(309): threadid=9: still suspended after undo (sc=1 dc=1 s=Y)
01-19 08:55:18.873: D/dalvikvm(309): GC_FOR_MALLOC freed 218 objects / 54816 bytes in 60ms
01-19 08:55:19.093: D/dalvikvm(309): threadid=9: still suspended after undo (sc=1 dc=1 s=Y)
01-19 08:55:19.093: D/dalvikvm(309): GC_FOR_MALLOC freed 140 objects / 65616 bytes in 59ms
01-19 08:55:19.224: D/dalvikvm(309): threadid=9: still suspended after undo (sc=1 dc=1 s=Y)
01-19 08:55:19.233: D/dalvikvm(309): GC_FOR_MALLOC freed 2701 objects / 161168 bytes in 58ms
01-19 08:55:19.403: D/dalvikvm(309): threadid=9: still suspended after undo (sc=1 dc=1 s=Y)
01-19 08:55:19.403: D/dalvikvm(309): GC_FOR_MALLOC freed 103 objects / 57120 bytes in 60ms
01-19 08:55:19.562: D/dalvikvm(309): threadid=9: still suspended after undo (sc=1 dc=1 s=Y)
01-19 08:55:19.562: D/dalvikvm(309): GC_EXTERNAL_ALLOC freed 84 objects / 60576 bytes in 58ms
01-19 08:55:20.932: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 08:55:20.932: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 08:55:20.942: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 08:55:22.832: D/dalvikvm(309): threadid=9: still suspended after undo (sc=1 dc=1 s=Y)
01-19 08:55:22.872: D/dalvikvm(309): GC_FOR_MALLOC freed 1773 objects / 124464 bytes in 112ms
01-19 08:55:23.282: D/dalvikvm(309): threadid=9: still suspended after undo (sc=1 dc=1 s=Y)
01-19 08:55:23.282: D/dalvikvm(309): GC_EXTERNAL_ALLOC freed 3640 objects / 214648 bytes in 59ms
01-19 08:55:26.492: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 08:55:26.492: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 08:55:26.502: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 08:55:26.502: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 08:55:26.612: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 08:55:50.372: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 08:57:40.116: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 09:06:16.113: D/dalvikvm(309): threadid=9: still suspended after undo (sc=1 dc=1 s=Y)
01-19 09:06:16.113: D/dalvikvm(309): GC_FOR_MALLOC freed 18114 objects / 543192 bytes in 77ms
01-19 09:06:52.039: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 09:09:00.393: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 09:09:00.404: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 09:09:00.483: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 09:09:00.483: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 09:09:00.493: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 09:09:00.493: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 09:09:00.493: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 09:10:27.498: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 09:10:27.498: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 09:10:27.502: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 09:10:27.502: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 09:10:27.502: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 09:10:27.502: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 09:10:27.502: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 09:10:27.502: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 09:10:41.474: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 09:10:41.474: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 09:10:41.487: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 09:10:41.487: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 09:10:41.487: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 09:11:00.062: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 09:11:07.979: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 09:11:07.979: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 09:11:07.979: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 09:11:07.983: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 09:11:08.153: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 09:11:56.832: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 09:18:53.793: D/dalvikvm(309): threadid=9: still suspended after undo (sc=1 dc=1 s=Y)
01-19 09:18:53.793: D/dalvikvm(309): GC_FOR_MALLOC freed 19776 objects / 576408 bytes in 76ms
01-19 09:23:16.797: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 09:23:16.797: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 09:23:16.797: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 09:23:16.802: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-19 09:23:17.072: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number

Non riesco a capire cosa intende per Bad file number

Offline bradipao

  • Moderatore globale
  • Utente storico
  • *****
  • Post: 4043
  • keep it simple
  • Respect: +567
    • Github
    • Google+
    • bradipao
    • Mostra profilo
  • Dispositivo Android:
    Nexus 5
  • Play Store ID:
    Bradipao
  • Sistema operativo:
    W7
Re:Parsing errato in importazione coordinate da xml
« Risposta #6 il: 19 Gennaio 2012, 10:41:02 CET »
0
Secondo me quell'errore è dovuto al fatto che in qualche modo richiami un Sensore, ma l'emulatore non ne ha.
NON rispondo a domande nei messaggi privati
Bradipao @ Play Store

Offline darkmax

  • Utente junior
  • **
  • Post: 62
  • Respect: 0
    • Mostra profilo
    • Emoe - Agenzia di comunicazione Torino
  • Dispositivo Android:
    Samsung Galaxy S 3
  • Sistema operativo:
    Mac OS X
Re:Parsing errato in importazione coordinate da xml
« Risposta #7 il: 19 Gennaio 2012, 11:24:04 CET »
0
Boh.. comunque l'applicazione va e me ne occuperò più tardi.. L'unica cosa è che non mi disegna i PinPoint.. Io nell'AsyncTask, tramite il metodo onPostExecute, gli faccio acquisire i valori delle coordinate dalla lista.. Ma non mi visualizza nulla sulla mappa.. perchè? ecco il codice:

Codice: [Seleziona]
package it.program.max;


import java.net.URL;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.OverlayItem;

import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.util.Log;

public class MyAsynTask extends AsyncTask<Context, Integer, String> {
       
        private Context myContext = null;

        /*
        public MyAsynTask(Context context) {
                this.myContext = context;
                // TODO Auto-generated constructor stub
        }
        */
        private final String MY_DEBUG_TAG = "Prova";
        private final String LIST_TAG = "Lista";
        private ArrayList<ParsedExampleDataSet> list = new ArrayList<ParsedExampleDataSet>();

        @Override
        protected String doInBackground(Context... params) {
               
        try {
                /* Create a URL we want to load some xml-data from. */
                URL url = new URL("http://opendata.5t.torino.it/get_pk");
                myContext = params[0];

                /* Get a SAXParser from the SAXPArserFactory. */
                SAXParserFactory spf = SAXParserFactory.newInstance();
                SAXParser sp = spf.newSAXParser();

                /* Get the XMLReader of the SAXParser we created. */
                XMLReader xr = sp.getXMLReader();
                /* Create a new ContentHandler and apply it to the XML-Reader*/
                ExampleHandler myExampleHandler = new ExampleHandler();
                xr.setContentHandler(myExampleHandler);
               
                /* Parse the xml-data from our URL. */
                xr.parse(new InputSource(url.openStream()));
                /* Parsing has finished. */
                 
                list = myExampleHandler.getParsedData();
                               
        } catch (Exception e) {
                /* Display any Error to the GUI. */
                Log.e(MY_DEBUG_TAG, "QueryError", e);
        }
       

               
                return "123";
        }
        @Override
        protected void onPostExecute(String result) {
                // TODO Auto-generated method stub
                super.onPostExecute(result);
                Activity activity=(Activity)myContext;
                MapView m = (MapView) activity.findViewById(R.id.mvMain);
                Drawable d = activity.getResources().getDrawable(R.drawable.parking);
               
                Log.d(LIST_TAG , ""+ list.size());
               
                Iterator<ParsedExampleDataSet> itr = list.iterator();
                while(itr.hasNext()){
               
                        ParsedExampleDataSet p = itr.next();
                       
                int x = (int)(p.getExtractedLat()*1E6);
                int y = (int)(p.getExtractedLng()*1E6);
                GeoPoint touchedPoint = m.getProjection().fromPixels(x, y);
               
                OverlayItem overlayItem = new OverlayItem(touchedPoint, "Prova", "Stringa");
                CustomPinPoint custom = new CustomPinPoint(d, activity);
                custom.insertPinpoint(overlayItem);
                List<Overlay> overlayList = m.getOverlays();
                overlayList.add(custom);
                }
               
       
               
               
               
        }
       
       
       
       
}

Offline darkmax

  • Utente junior
  • **
  • Post: 62
  • Respect: 0
    • Mostra profilo
    • Emoe - Agenzia di comunicazione Torino
  • Dispositivo Android:
    Samsung Galaxy S 3
  • Sistema operativo:
    Mac OS X
Re:Parsing errato in importazione coordinate da xml
« Risposta #8 il: 19 Gennaio 2012, 14:36:47 CET »
0
qualche idea?