1

I made some classes to read KML files, (using SAX) in Java. I test it, and it works fine. Then I made my jar, and imported it to android project. But when I try to read the SAME kML, I don't got any result. The parser returns me empty list(vector)

Thats how I made in Java:

Vector<Point> listPoints = new Vector<Point>();
String src = "C:/Users/A556520/Documents/Proyectos/PolygonDoubleKML/res/Glorias_def.kml";       
InputStream inputStream =new FileInputStream(src);      
ReaderKML kmlreader = new ReaderKML(inputStream);
time_start = System.currentTimeMillis();
listPoints = kmlreader.parseKML();
time_end = System.currentTimeMillis();
System.out.println("Tiempo de ejecución: "+ (time_end-time_start)/1000f);

And the output its correct --> Tiempo de ejecución: 0.073 || Npoints = 401

Then as I told, I import the jar, to the Android project, and thats how I do:

Vector<Point> lista;
Polygon glorias;
ReaderKML kmlReader;
String pathKML = "~res/raw/glorias_def.kml";
InputStream input_kml;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
input_kml = getResources().openRawResource(R.raw.glorias_def);
kmlReader = new ReaderKML(input_kml);
lista = kmlReader.parseKML();       
}

protected void onStart() {
    super.onStart();        
    tv_1.setText("Npoints = "+Integer.toString(lista.size()));
}

And what I get in the textView is Npoints = 0, when it has to be Npoints = 401... I don't understand what is wrong... The kml file, is inside ~res/raw and it's the same that I used to test in Java.

4

0 回答 0