Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid application stopped unexpected
    primarykey
    data
    text
    <p>I'm developing an andorid application using google maps version 2. I read a xml file using DOM to get data I need. Everything is good with the xml parsing (I see that from the logcat). The data that is read I put into ArrayList of type Hotel (a class of mine). When I try to put markers using lat and lng information that I read my application stops. But it stops only when I read in for cycle, not when I read only one (for example the last added in the list). I try to short the list to half, but it doesn;t work also.</p> <p>Here is the code: Hoteli.java:</p> <pre><code>public class Hoteli extends FragmentActivity { GoogleMap map; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_hoteli); setTitle("Хотели"); ArrayList&lt;Hotel&gt; hoteli= new ArrayList&lt;Hotel&gt;(); Hotel h=null; Log.d("", "pred try delot"); try { InputStream in = this.getResources().openRawResource(R.raw.hoteli); StringBuffer str = new StringBuffer(); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document document = db.parse(in, null); document.getDocumentElement().normalize(); Log.d("", "Root element :" + document.getDocumentElement().getNodeName()); NodeList nList = document.getElementsByTagName("hotel"); Log.d("", "----------------------------"); Log.d("",Integer.toString(nList.getLength())); for (int temp = 0; temp &lt; nList.getLength(); temp++) { h= new Hotel(); Node nNode = nList.item(temp); Log.d("", "\nCurrent Element :" + nNode.getNodeName()); if (nNode.getNodeType() == Node.ELEMENT_NODE) { Element eElement = (Element) nNode; Log.d("", "Staff hotel : " + eElement.getAttribute("hotel")); h= new Hotel(); Log.d("", "Name: " + eElement.getElementsByTagName("name").item(0) .getTextContent()); h.setName(eElement.getElementsByTagName("name").item(0) .getTextContent()); Log.d("", "City : " + eElement.getElementsByTagName("city").item(0) .getTextContent()); h.setCity(eElement.getElementsByTagName("city").item(0) .getTextContent()); Log.d("", "Lat : " + eElement.getElementsByTagName("lat").item(0) .getTextContent()); h.setLat(eElement.getElementsByTagName("lat").item(0) .getTextContent()); Log.d("", "Lng : " + eElement.getElementsByTagName("lng").item(0) .getTextContent()); h.setLng( eElement.getElementsByTagName("lng").item(0) .getTextContent()); Log.d("", "Stars : " + eElement.getElementsByTagName("stars") .item(0).getTextContent()); h.setStars(eElement.getElementsByTagName("stars") .item(0).getTextContent()); Log.d("", "Description : " + eElement .getElementsByTagName("desciption") .item(0).getTextContent()); h.setDescription(eElement .getElementsByTagName("desciption") .item(0).getTextContent()); hoteli.add(h); } } } catch (Exception err) { err.printStackTrace(); } map = ((SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.mapaHoteli)).getMap(); int halfLength= hoteli.size()/2; for(int i=0;i&lt;halfLength;i++) { final LatLng currentPositionLatLng=new LatLng(Double.parseDouble(hoteli.get(i).getLat()), Double.parseDouble(hoteli.get(i).getLng())); Marker currentPosition = map.addMarker(new MarkerOptions() .position(currentPositionLatLng) .title("\"" +hoteli.get(i).getName()+"\""+ " "+ hoteli.get(i).getStars()+ " ѕвезди") .snippet(hoteli.get(i).getCity() + hoteli.get(i).getDescription()) .icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_launcher))); }} @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.hoteli, menu); return true; } } </code></pre> <p>Hotel.java:</p> <pre><code>public class Hotel { String name; String city; String lat; String lng; String stars; String description; public Hotel() {} public String getName() { return name; } public void setName(String name) { this.name = name; } public String getCity() { return city; } public void setCity(String city) { this.city = city; } public String getLat() { return lat; } public void setLat(String lat) { this.lat = lat; } public String getLng() { return lng; } public void setLng(String lng) { this.lng = lng; } public String getStars() { return stars; } public void setStars(String stars) { this.stars = stars; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } } </code></pre> <p>Error from logcat:</p> <pre><code>05-25 22:17:56.937: E/AndroidRuntime(18639): FATAL EXCEPTION: main 05-25 22:17:56.937: E/AndroidRuntime(18639): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.probna/com.example.probna.Hoteli}: java.lang.NumberFormatException 05-25 22:17:56.937: E/AndroidRuntime(18639): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1670) 05-25 22:17:56.937: E/AndroidRuntime(18639): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1686) 05-25 22:17:56.937: E/AndroidRuntime(18639): at android.app.ActivityThread.access$1500(ActivityThread.java:118) 05-25 22:17:56.937: E/AndroidRuntime(18639): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:932) 05-25 22:17:56.937: E/AndroidRuntime(18639): at android.os.Handler.dispatchMessage(Handler.java:99) 05-25 22:17:56.937: E/AndroidRuntime(18639): at android.os.Looper.loop(Looper.java:130) 05-25 22:17:56.937: E/AndroidRuntime(18639): at android.app.ActivityThread.main(ActivityThread.java:3706) 05-25 22:17:56.937: E/AndroidRuntime(18639): at java.lang.reflect.Method.invokeNative(Native Method) 05-25 22:17:56.937: E/AndroidRuntime(18639): at java.lang.reflect.Method.invoke(Method.java:507) 05-25 22:17:56.937: E/AndroidRuntime(18639): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841) 05-25 22:17:56.937: E/AndroidRuntime(18639): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599) 05-25 22:17:56.937: E/AndroidRuntime(18639): at dalvik.system.NativeStart.main(Native Method) 05-25 22:17:56.937: E/AndroidRuntime(18639): Caused by: java.lang.NumberFormatException 05-25 22:17:56.937: E/AndroidRuntime(18639): at org.apache.harmony.luni.util.FloatingPointParser.parseDblImpl(Native Method) 05-25 22:17:56.937: E/AndroidRuntime(18639): at org.apache.harmony.luni.util.FloatingPointParser.parseDouble(FloatingPointParser.java:283) 05-25 22:17:56.937: E/AndroidRuntime(18639): at java.lang.Double.parseDouble(Double.java:318) 05-25 22:17:56.937: E/AndroidRuntime(18639): at com.example.probna.Hoteli.onCreate(Hoteli.java:131) 05-25 22:17:56.937: E/AndroidRuntime(18639): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 05-25 22:17:56.937: E/AndroidRuntime(18639): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1634) 05-25 22:17:56.937: E/AndroidRuntime(18639): ... 11 more </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.
    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