Re: [android-developers] Comparing getLatitude() and getLongitude() to null

2011-07-07 Thread TreKing
On Thu, Jul 7, 2011 at 12:22 PM, Raghav Sood raghavs...@gmail.com wrote: I am getting an error that I can not compare these values as they are Doubles in nature and null is not valid here with ||. How can I compare these? As the error indicates, they are not object that are comparable to

Re: [android-developers] Comparing getLatitude() and getLongitude() to null

2011-07-07 Thread Raghav Sood
I am trying to guard against them being null. I am getting error reports from users via ACRA that these are returning null sometimes. Hence the safeguard. On Thu, Jul 7, 2011 at 11:05 PM, TreKing treking...@gmail.com wrote: On Thu, Jul 7, 2011 at 12:22 PM, Raghav Sood raghavs...@gmail.com

Re: [android-developers] Comparing getLatitude() and getLongitude() to null

2011-07-07 Thread TreKing
On Thu, Jul 7, 2011 at 12:38 PM, Raghav Sood raghavs...@gmail.com wrote: I am trying to guard against them being null. I am getting error reports from users via ACRA that these are returning null sometimes. That's not possible. Double-check your logs and what variable they point to. The

Re: [android-developers] Comparing getLatitude() and getLongitude() to null

2011-07-07 Thread Raghav Sood
TreKing I had this in a previous thread to but that problem was fixed. This is another one causing the same error/ java.lang.NullPointerException at com.raghavsood.findme.MyPositionOverlay.draw(MyPositionOverlay.java:37) at com.google.android.maps.Overlay.draw(Overlay.java:179) at

Re: [android-developers] Comparing getLatitude() and getLongitude() to null

2011-07-07 Thread Mark Murphy
Your location variable is null. On Thu, Jul 7, 2011 at 1:45 PM, Raghav Sood raghavs...@gmail.com wrote: Double latitude = location.getLatitude()*1E6; It is a NullPointerException so I suppose it is returning null. -- Mark Murphy (a Commons Guy) http://commonsware.com |

Re: [android-developers] Comparing getLatitude() and getLongitude() to null

2011-07-07 Thread TreKing
On Thu, Jul 7, 2011 at 12:45 PM, Raghav Sood raghavs...@gmail.com wrote: Double latitude = location.getLatitude()*1E6; It is a NullPointerException so I suppose it is returning null. NullPointerExceptions are cause by *objects* that are set to null. The only *object* in that statement is

Re: [android-developers] Comparing getLatitude() and getLongitude() to null

2011-07-07 Thread Raghav Sood
But the thing is location can't be null. If it was the app wouldn't have reached here. I check for location being null in my main activity: if (location != null) { // Update my location marker positionOverlay.setLocation(location); Only the does MyPositionOverlay receive

Re: [android-developers] Comparing getLatitude() and getLongitude() to null

2011-07-07 Thread Mark Murphy
On Thu, Jul 7, 2011 at 2:00 PM, Raghav Sood raghavs...@gmail.com wrote: But the thing is location can't be null. If it was the app wouldn't have reached here. I check for location being null in my main activity: if (location != null) {          // Update my location marker        

Re: [android-developers] Comparing getLatitude() and getLongitude() to null

2011-07-07 Thread Raghav Sood
Okay. Maybe I am missing something here but AFAIK the if statement check to see that location is not equal to null and if that is true (location not being null) it passes it on to the Overlay. Did I get that right? On Thu, Jul 7, 2011 at 11:36 PM, Mark Murphy mmur...@commonsware.comwrote: On

Re: [android-developers] Comparing getLatitude() and getLongitude() to null

2011-07-07 Thread TreKing
On Thu, Jul 7, 2011 at 1:00 PM, Raghav Sood raghavs...@gmail.com wrote: But the thing is location can't be null. It can and it is. If it was the app wouldn't have reached here. Correct. But this is not where the crash is. I check for location being null in my main activity: if

Re: [android-developers] Comparing getLatitude() and getLongitude() to null

2011-07-07 Thread TreKing
On Thu, Jul 7, 2011 at 1:11 PM, Raghav Sood raghavs...@gmail.com wrote: Okay. Maybe I am missing something here but AFAIK the if statement check to see that location is not equal to null and if that is true (location not being null) it passes it on to the Overlay. Did I get that right?

Re: [android-developers] Comparing getLatitude() and getLongitude() to null

2011-07-07 Thread Raghav Sood
Right. Got it now. Basically I need to check location for null twice. Once in the Activity and once in the Overlay. Thanks On Thu, Jul 7, 2011 at 11:44 PM, TreKing treking...@gmail.com wrote: On Thu, Jul 7, 2011 at 1:00 PM, Raghav Sood raghavs...@gmail.com wrote: But the thing is location

Re: [android-developers] Comparing getLatitude() and getLongitude() to null

2011-07-07 Thread Raghav Sood
I needed a custom graphic and text on the location point and the book I used said it was not possible with MyLocationOverlay. Also later on I plan on adding a few more things that would not work with MyLocationOverlay. Thanks P.S. If I have a method in my Activity to display a toast can I safely

Re: [android-developers] Comparing getLatitude() and getLongitude() to null

2011-07-07 Thread TreKing
On Thu, Jul 7, 2011 at 1:24 PM, Raghav Sood raghavs...@gmail.com wrote: P.S. If I have a method in my Activity to display a toast can I safely call it from the Overlay class? Well, sure, with a valid reference to the Activity. But injecting a dependency on the Activity into your Overlay to

Re: [android-developers] Comparing getLatitude() and getLongitude() to null

2011-07-07 Thread TreKing
On Thu, Jul 7, 2011 at 1:24 PM, Raghav Sood raghavs...@gmail.com wrote: I needed a custom graphic and text on the location point and the book I used said it was not possible with MyLocationOverlay. I like this book less and less. MyLocationOverlay is just another Overlay that handles the

Re: [android-developers] Comparing getLatitude() and getLongitude() to null

2011-07-07 Thread Raghav Sood
I know :(. But I am at a loss as to how to notify my users that there is something wrong. On Thu, Jul 7, 2011 at 11:59 PM, TreKing treking...@gmail.com wrote: On Thu, Jul 7, 2011 at 1:24 PM, Raghav Sood raghavs...@gmail.com wrote: P.S. If I have a method in my Activity to display a toast can

Re: [android-developers] Comparing getLatitude() and getLongitude() to null

2011-07-07 Thread TreKing
On Thu, Jul 7, 2011 at 1:33 PM, Raghav Sood raghavs...@gmail.com wrote: I know :(. But I am at a loss as to how to notify my users that there is something wrong. Well your overlay has access to the MapView on which it is drawing, which in turn has a Context, which is all you really need for

Re: [android-developers] Comparing getLatitude() and getLongitude() to null

2011-07-07 Thread Raghav Sood
I should probably change it. Seeing as this book has given me more errors than knowledge I think I'd get another one. Maybe one of Mark's. @Mark: Where can I get your book in New Delhi, India? I can't find it at any of the major stores and I don't have any virtual cash or credit card to buy it

Re: [android-developers] Comparing getLatitude() and getLongitude() to null

2011-07-07 Thread Kostya Vasilyev
You can use a status bar notification, or implement some sort of callback (listener) that takes you back to the activity, where you can e.g. display a dialog: myObject.setErrorListener(new ErrorListener() { @Override public void somethingBadHappened( ) { // display a

Re: [android-developers] Comparing getLatitude() and getLongitude() to null

2011-07-07 Thread Raghav Sood
I think I'll go with Status Bar notification. I might add a form later asking them whether or not they have a SIM card and ship it as a custom variable with ACRA. (Only reason I can think of for the null value is a missing SIM card as I use the cell network for location.) And before someone tells

Re: [android-developers] Comparing getLatitude() and getLongitude() to null

2011-07-07 Thread Mark Murphy
On Thu, Jul 7, 2011 at 2:38 PM, Raghav Sood raghavs...@gmail.com wrote: @Mark: Where can I get your book in New Delhi, India? I can't find it at any of the major stores and I don't have any virtual cash or credit card to buy it online. (A small downside of being 14.) You're 14? I take back

Re: [android-developers] Comparing getLatitude() and getLongitude() to null

2011-07-07 Thread Raghav Sood
Thanks Mark. I really appreciate all the help all of you have given me so far. I got your books and they are a lot more straightforward than the one I was using so far. I won't forget to sleep. In fact I am going to do it now. It is about 00:30 here in India. Thanks a lot for your help. On Fri,

Re: [android-developers] Comparing getLatitude() and getLongitude() to null

2011-07-07 Thread Mark Murphy
On Thu, Jul 7, 2011 at 3:09 PM, Raghav Sood raghavs...@gmail.com wrote: Thanks Mark. I really appreciate all the help all of you have given me so far. I got your books and they are a lot more straightforward than the one I was using so far. BTW, I just uploaded a new round of editions, so you