NullPointerException in mapcontroller.animateTo

Put problem concerning MapActivities, MapViews, Overlays and GPS in this forum.

NullPointerException in mapcontroller.animateTo

Postby YellowJK » Sat May 08, 2010 6:31 pm

We seen to have found a bug in our application and are at a lose on what to do. Our application simply has a mapview tied to a mapcontroller that we use to get the users gps location and display it on a map. We occasionaly check for an updated position and animate to the new one. It seems that during this animation process it sometimes crashes with a null pointer exception. I'm not quite sure why it crashes. We can't seen to reproduce the error on our end but we receive reports from our customers with the crash. Here is the stack trace provided to us:


com.TwentyCodes.android.FindMyCarLite.FindMyCar.onLocationChanged(FindMyCar.java:437)
android.location.LocationManager$ListenerTransport._handleMessage(LocationManager.java:179)
android.location.LocationManager$ListenerTransport.access$000(LocationManager.java:112)
android.location.LocationManager$ListenerTransport$1.handleMessage(LocationManager.java:128)
android.os.Handler.dispatchMessage(Handler.java:99)
android.os.Looper.loop(Looper.java:123)
android.app.ActivityThread.main(ActivityThread.java:4363)
java.lang.reflect.Method.invokeNative(Native Method)
java.lang.reflect.Method.invoke(Method.java:521)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
dalvik.system.NativeStart.main(Native Method)


here is FindMyCar.java:437
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. mapController.animateTo(user);
Parsed in 0.030 seconds, using GeSHi 1.0.8.4

and this is the whole method.
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public void onLocationChanged(Location loc) {
  2.         /*
  3.          * created variable to fix bug that mlcUserLocOverlay.getMyLocation()
  4.          * can become null between if statement and mapController.animateTo()
  5.          */
  6.         GeoPoint user = mlcUserLocOverlay.getMyLocation();
  7.         if (user != null){
  8.                 mapController.animateTo(user);
  9.         }
  10.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


The only thing we noticed is that the reports seem to only be coming from droids running 2.1. We tested on mt3g and g1's running from 1.5 to 2.1. Any ideas?
YellowJK
Freshman
Freshman
 
Posts: 9
Joined: Fri Apr 09, 2010 12:19 am

Top

Postby nicholas.hauschild » Sat May 08, 2010 9:46 pm

Hello YelloJK,

It appears that you have your mapController set up as a member variable. At what point in your code do you initialize it, and do you ever reassign in anywhere in your code?

Good luck!
-Nick
nicholas.hauschild
Master Developer
Master Developer
 
Posts: 310
Joined: Fri Dec 04, 2009 4:50 am

Postby YellowJK » Sun May 09, 2010 12:19 am

we initialized mapControler in onCreate with this line

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. mapController = mvMap.getController();
  3.  
  4.  
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


the only timer we modify it is in onDestroy, where we set it to null before we run System.gc()
YellowJK
Freshman
Freshman
 
Posts: 9
Joined: Fri Apr 09, 2010 12:19 am

Postby YellowJK » Sun May 09, 2010 6:01 am

what if instead of using a variable for the Map Controler i just do this

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. GeoPoint user = mlcUserLocOverlay.getMyLocation();
  3.  
  4. if (user != null){
  5.  
  6.      mvMap.getController().animateTo(user);
  7.  
  8. }
  9.  
  10.  
Parsed in 0.048 seconds, using GeSHi 1.0.8.4


do you guys think that it would make a difference :?:
YellowJK
Freshman
Freshman
 
Posts: 9
Joined: Fri Apr 09, 2010 12:19 am

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 4 guests