Note that there are some explanatory texts on larger screens.

plurals
  1. POWeird error report from MapActivity
    primarykey
    data
    text
    <p>I would like to ask for some help to understand an error report. I have an app uploaded on the Android market, or so called Google Play theese days, and one of my user had a force close, and pressed the "Report" button, so I recieved his report. What I know:</p> <ul> <li>it must come from the MapActivity of my app</li> <li>I have custom markers on the map</li> <li>at the time of the report, the site could be down from where I would fetch the data for the markers, so it is possible, that there was 0 alive marker at the time of the report</li> <li>I think that there is no possible nullpointer errors on my side, I think I have it all covered</li> <li>the maximum numbers of the markers is 1(yea it sounds silly for now, I will change it in the future tho, so it is fine that the app can handle multiple markers)</li> <li>the error report does not contain ANY reference to my code, the Stacktrace is pointing on the android maps</li> <li>from what I understand, some zooming action could cause the whole thing, not sure tho</li> </ul> <p>The mentioned stacktrace:</p> <pre><code>java.lang.NullPointerException at android.graphics.Canvas.&lt;init&gt;(Canvas.java:82) at com.google.android.maps.ZoomHelper.createSnapshot(ZoomHelper.java:447) at com.google.android.maps.ZoomHelper.doZoom(ZoomHelper.java:151) at com.google.android.maps.ZoomHelper.doZoom(ZoomHelper.java:140) at com.google.android.maps.MapView.doZoom(MapView.java:1478) at com.google.android.maps.MapView.doZoom(MapView.java:1487) at com.google.android.maps.MapView$6.onZoom(MapView.java:1442) at android.widget.ZoomButtonsController$3.onClick(ZoomButtonsController.java:268) at android.view.View.performClick(View.java:2420) at android.view.View$PerformClick.run(View.java:8844) at android.os.Handler.handleCallback(Handler.java:587) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:123) at android.app.ActivityThread.main(ActivityThread.java:4627) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:521) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) at dalvik.system.NativeStart.main(Native Method) </code></pre> <p>I have no idea what to do, even tho there is only this 1 report from 2000~ users, it still bugs me, and I would like to have it covered, and it is always good, to learn something new at the end of the day. :)</p> <p>Some snippets from my code:</p> <p>This is how I create the Map:</p> <pre><code>protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.map); isCentered=false; map = (MapView)findViewById(R.id.map_view); map=(MapView)findViewById(R.id.map_view); map.setBuiltInZoomControls(true); extras = this.getIntent().getExtras(); if(extras!=null) code=extras.getString("code"); if(!isOnline()) { Toast.makeText(this, "Aktív internetkapcsolat szükséges!", Toast.LENGTH_SHORT).show(); return; } refreshTrain(); } </code></pre> <p>After creating the map, the refreshTrain() method starts an AsyncTask, which fetches the data from a website, and sets up the markers in the onPostExecute(Void param) like this:</p> <pre><code> protected void onPostExecute(Void param) { try { if(result.length()&lt;10) //the site is offline or the request is not valid { Toast.makeText(ctx, "Nem érhetőek el a térképadatok, próbáld később...", Toast.LENGTH_SHORT).show(); return; } JSONObject json = new JSONObject(result); //parse the result and set up the coordinates latitude=json.getString("lat"); longitude=json.getString("lon"); double _lat=Double.parseDouble(latitude); double _lon=Double.parseDouble(longitude); int lat=(int)(_lat*1E6); int lon=(int)(_lon*1E6); event_time=getJson(json, "event_time"); //get additional informations about the train start_station=getJson(json, "start_station"); end_station=getJson(json, "end_station"); MapController mc = map.getController(); //set the markers List&lt;Overlay&gt; list = map.getOverlays(); list.clear(); Drawable drawable = getResources().getDrawable(R.drawable.pin); Markers markers = new Markers(drawable); GeoPoint p = new GeoPoint(lat, lon); OverlayItem item = new OverlayItem(p, "vonat", "snippet"); markers.addOverlayItem(item); mc.setCenter(p); mc.animateTo(p); if(!isCentered) //dont change the zoom after each refresh, only on the first creation { mc.setZoom(12); isCentered=true; } list.add(markers); } catch(JSONException e) { Log.e(TAG,e.getMessage()); } } } </code></pre> <p>Finally, my marker class is looking like this:</p> <pre><code>private class Markers extends com.google.android.maps.ItemizedOverlay&lt;OverlayItem&gt; { private ArrayList&lt;OverlayItem&gt; mOverlays = new ArrayList&lt;OverlayItem&gt;(); public Markers(Drawable defaultMarker) { super(boundCenter(defaultMarker)); } @Override protected OverlayItem createItem(int i) { return mOverlays.get(i); } @Override public int size() { return mOverlays.size(); } public void addOverlayItem(OverlayItem item) { mOverlays.add(item); populate(); } @Override protected boolean onTap(int index) { //display the additional infos on tap AlertDialog.Builder dialog = new AlertDialog.Builder(ctx); dialog.setTitle("Frissítve: "+event_time); dialog.setMessage(start_station+" \u2192 "+end_station); dialog.show(); return true; } } </code></pre> <p>cheers</p> <p>edit: code added</p> <p>edit2: from what I've found so far(nothing sure) the error could come from the Toast message. At the errors time, I wouldnt check if there is any active connection(no isOnline() in the onCreate), and wouldn't notify the user, if the site isnt available, so if it is the Toast, it is coming from the refreshing thingie in the AsyncTask, which is fired in the onPreExecute() method, nothing else happens there. Im only guessing, but maybe...</p>
    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