Re: [android-developers] Puzzling crash report. Location app doesn't work if the GPS is on
How are you getting that Location that is null? On Thu, Jul 7, 2011 at 8:18 AM, Raghav Sood raghavs...@gmail.com wrote: Hi all I wrote an app that gets and displays your location on a map. I am using the Google Maps service to render the map. The app has been live for less than two hours and I have received 33 crash reports (using ACRA). I have been able to recreate the problem. The app works fine if the GPS is off but if it is switched on the app force closes. The stack trace reads: java.lang.NullPointerException at com.raghavsood.findme.MyPositionOverlay.draw(MyPositionOverlay.java:37) at com.google.android.maps.Overlay.draw(Overlay.java:179) at com.google.android.maps.OverlayBundle.draw(OverlayBundle.java:45) at com.google.android.maps.MapView.onDraw(MapView.java:494) at android.view.View.draw(View.java:6818) at android.view.ViewGroup.drawChild(ViewGroup.java:1640) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367) at android.view.ViewGroup.drawChild(ViewGroup.java:1638) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367) at android.view.View.draw(View.java:6821) at android.widget.FrameLayout.draw(FrameLayout.java:354) at android.view.ViewGroup.drawChild(ViewGroup.java:1640) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367) at android.view.ViewGroup.drawChild(ViewGroup.java:1638) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367) at android.view.View.draw(View.java:6821) at android.widget.FrameLayout.draw(FrameLayout.java:354) at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1944) at android.view.ViewRoot.draw(ViewRoot.java:1432) at android.view.ViewRoot.performTraversals(ViewRoot.java:1174) at android.view.ViewRoot.handleMessage(ViewRoot.java:1752) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:123) at android.app.ActivityThread.main(ActivityThread.java:4632) 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:858) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) at dalvik.system.NativeStart.main(Native Method) I don't know why there is a NullPointerException exception at MyPositionOverlay on line 37. The line in question reads: Double latitude = location.getLatitude()*1E6; The same code works fine if GPS is off. The app is https://market.android.com/details?id=com.raghavsood.findme Does anyone know what could be causing this and how to fix it? Thanks -- Raghav Sood http://www.raghavsood.com/ http://www.androidappcheck.com/ http://www.telstop.tel/ -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Android Training...At Your Office: http://commonsware.com/training -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Puzzling crash report. Location app doesn't work if the GPS is on
Exactly my point. When the GPS is on it returns null for the location, but if the GPS is off then the cell phone tower location works fine. Is there any way that I can set my app to triangulate using only the cellphone network? Thanks On Thu, Jul 7, 2011 at 5:58 PM, Mark Murphy mmur...@commonsware.com wrote: How are you getting that Location that is null? On Thu, Jul 7, 2011 at 8:18 AM, Raghav Sood raghavs...@gmail.com wrote: Hi all I wrote an app that gets and displays your location on a map. I am using the Google Maps service to render the map. The app has been live for less than two hours and I have received 33 crash reports (using ACRA). I have been able to recreate the problem. The app works fine if the GPS is off but if it is switched on the app force closes. The stack trace reads: java.lang.NullPointerException at com.raghavsood.findme.MyPositionOverlay.draw(MyPositionOverlay.java:37) at com.google.android.maps.Overlay.draw(Overlay.java:179) at com.google.android.maps.OverlayBundle.draw(OverlayBundle.java:45) at com.google.android.maps.MapView.onDraw(MapView.java:494) at android.view.View.draw(View.java:6818) at android.view.ViewGroup.drawChild(ViewGroup.java:1640) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367) at android.view.ViewGroup.drawChild(ViewGroup.java:1638) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367) at android.view.View.draw(View.java:6821) at android.widget.FrameLayout.draw(FrameLayout.java:354) at android.view.ViewGroup.drawChild(ViewGroup.java:1640) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367) at android.view.ViewGroup.drawChild(ViewGroup.java:1638) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367) at android.view.View.draw(View.java:6821) at android.widget.FrameLayout.draw(FrameLayout.java:354) at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1944) at android.view.ViewRoot.draw(ViewRoot.java:1432) at android.view.ViewRoot.performTraversals(ViewRoot.java:1174) at android.view.ViewRoot.handleMessage(ViewRoot.java:1752) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:123) at android.app.ActivityThread.main(ActivityThread.java:4632) 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:858) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) at dalvik.system.NativeStart.main(Native Method) I don't know why there is a NullPointerException exception at MyPositionOverlay on line 37. The line in question reads: Double latitude = location.getLatitude()*1E6; The same code works fine if GPS is off. The app is https://market.android.com/details?id=com.raghavsood.findme Does anyone know what could be causing this and how to fix it? Thanks -- Raghav Sood http://www.raghavsood.com/ http://www.androidappcheck.com/ http://www.telstop.tel/ -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Android Training...At Your Office: http://commonsware.com/training -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Raghav Sood http://www.raghavsood.com/ http://www.androidappcheck.com/ http://www.telstop.tel/ -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Puzzling crash report. Location app doesn't work if the GPS is on
In brief, Mark wanted to see the code of the null Location acquisition using GPS. 2011/7/7 Raghav Sood raghavs...@gmail.com Exactly my point. When the GPS is on it returns null for the location, but if the GPS is off then the cell phone tower location works fine. Is there any way that I can set my app to triangulate using only the cellphone network? Thanks On Thu, Jul 7, 2011 at 5:58 PM, Mark Murphy mmur...@commonsware.comwrote: How are you getting that Location that is null? On Thu, Jul 7, 2011 at 8:18 AM, Raghav Sood raghavs...@gmail.com wrote: Hi all I wrote an app that gets and displays your location on a map. I am using the Google Maps service to render the map. The app has been live for less than two hours and I have received 33 crash reports (using ACRA). I have been able to recreate the problem. The app works fine if the GPS is off but if it is switched on the app force closes. The stack trace reads: java.lang.NullPointerException at com.raghavsood.findme.MyPositionOverlay.draw(MyPositionOverlay.java:37) at com.google.android.maps.Overlay.draw(Overlay.java:179) at com.google.android.maps.OverlayBundle.draw(OverlayBundle.java:45) at com.google.android.maps.MapView.onDraw(MapView.java:494) at android.view.View.draw(View.java:6818) at android.view.ViewGroup.drawChild(ViewGroup.java:1640) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367) at android.view.ViewGroup.drawChild(ViewGroup.java:1638) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367) at android.view.View.draw(View.java:6821) at android.widget.FrameLayout.draw(FrameLayout.java:354) at android.view.ViewGroup.drawChild(ViewGroup.java:1640) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367) at android.view.ViewGroup.drawChild(ViewGroup.java:1638) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367) at android.view.View.draw(View.java:6821) at android.widget.FrameLayout.draw(FrameLayout.java:354) at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1944) at android.view.ViewRoot.draw(ViewRoot.java:1432) at android.view.ViewRoot.performTraversals(ViewRoot.java:1174) at android.view.ViewRoot.handleMessage(ViewRoot.java:1752) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:123) at android.app.ActivityThread.main(ActivityThread.java:4632) 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:858) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) at dalvik.system.NativeStart.main(Native Method) I don't know why there is a NullPointerException exception at MyPositionOverlay on line 37. The line in question reads: Double latitude = location.getLatitude()*1E6; The same code works fine if GPS is off. The app is https://market.android.com/details?id=com.raghavsood.findme Does anyone know what could be causing this and how to fix it? Thanks -- Raghav Sood http://www.raghavsood.com/ http://www.androidappcheck.com/ http://www.telstop.tel/ -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Android Training...At Your Office: http://commonsware.com/training -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Raghav Sood http://www.raghavsood.com/ http://www.androidappcheck.com/ http://www.telstop.tel/ -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at
Re: [android-developers] Puzzling crash report. Location app doesn't work if the GPS is on
On Thu, Jul 7, 2011 at 7:18 AM, Raghav Sood raghavs...@gmail.com wrote: Does anyone know what could be causing this and how to fix it? Are you waiting for the GPS to actually report that it found a valid location ... ? - TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered devices -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Puzzling crash report. Location app doesn't work if the GPS is on
On Thu, Jul 7, 2011 at 9:28 AM, Raghav Sood raghavs...@gmail.com wrote: I have a app that triangulates the users location and displays it on a map without using the GPS. As long as the GPS is off the app does its job perfectly. The moment someone turns the GPS on the app force closes and gives a NullPointerException on line 37 of MyPositionOverlay which is given above. If needed I am willing to share the source code for the entire project as there is nothing special in it. It is attached with this mail. I would like this group's help on the fact as to why the app force closes when the GPS is turned on and how do I fix it. The app does not use the GPS at all. First, your overlay's location data member will be null sometimes, the way this is written. getLastKnownLocation() can return null at any time, and in that case, you don't have a Location to work with. You will need to either add intelligence to the overlay to handle this case, or not set up the overlay until you have a Location. Second, you are using GPS, the way this is written. More specifically, you are using the Criteria system, which will return GPS as a possible provider. Given your specific Criteria setup, if GPS is available, it probably is the best provider. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Android Training...At Your Office: http://commonsware.com/training -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Puzzling crash report. Location app doesn't work if the GPS is on
On Thu, Jul 7, 2011 at 8:28 AM, Raghav Sood raghavs...@gmail.com wrote: I would like this group's help on the fact as to why the app force closes when the GPS is turned on and how do I fix it. The app does not use the GPS at all. Are you sure about that? When GPS is on, what does getBestProvider return? - TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered devices -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Puzzling crash report. Location app doesn't work if the GPS is on
I am aware of the last know location returning null. As for my code using GPS, the book that I learnt geo services said that this shouldn't happen. Seems they were wrong. Coming back to the point. Is there any way to make sure that the app does not use GPS? That is even if GPS is on the app only uses the cell network? The whole point of my app was to provide the location without the GPS being used. Can I set the provider of the location? Thanks On Thu, Jul 7, 2011 at 7:06 PM, Mark Murphy mmur...@commonsware.com wrote: On Thu, Jul 7, 2011 at 9:28 AM, Raghav Sood raghavs...@gmail.com wrote: I have a app that triangulates the users location and displays it on a map without using the GPS. As long as the GPS is off the app does its job perfectly. The moment someone turns the GPS on the app force closes and gives a NullPointerException on line 37 of MyPositionOverlay which is given above. If needed I am willing to share the source code for the entire project as there is nothing special in it. It is attached with this mail. I would like this group's help on the fact as to why the app force closes when the GPS is turned on and how do I fix it. The app does not use the GPS at all. First, your overlay's location data member will be null sometimes, the way this is written. getLastKnownLocation() can return null at any time, and in that case, you don't have a Location to work with. You will need to either add intelligence to the overlay to handle this case, or not set up the overlay until you have a Location. Second, you are using GPS, the way this is written. More specifically, you are using the Criteria system, which will return GPS as a possible provider. Given your specific Criteria setup, if GPS is available, it probably is the best provider. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Android Training...At Your Office: http://commonsware.com/training -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Raghav Sood http://www.raghavsood.com/ http://www.androidappcheck.com/ http://www.telstop.tel/ -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Puzzling crash report. Location app doesn't work if the GPS is on
@TreKing: getBestProvider(); returns GPS but as my app is perfectly functional without the GPS I would like to use the cell network even when GPS is available. Is there any way to do so? Thanks On Thu, Jul 7, 2011 at 7:13 PM, Raghav Sood raghavs...@gmail.com wrote: I am aware of the last know location returning null. As for my code using GPS, the book that I learnt geo services said that this shouldn't happen. Seems they were wrong. Coming back to the point. Is there any way to make sure that the app does not use GPS? That is even if GPS is on the app only uses the cell network? The whole point of my app was to provide the location without the GPS being used. Can I set the provider of the location? Thanks On Thu, Jul 7, 2011 at 7:06 PM, Mark Murphy mmur...@commonsware.comwrote: On Thu, Jul 7, 2011 at 9:28 AM, Raghav Sood raghavs...@gmail.com wrote: I have a app that triangulates the users location and displays it on a map without using the GPS. As long as the GPS is off the app does its job perfectly. The moment someone turns the GPS on the app force closes and gives a NullPointerException on line 37 of MyPositionOverlay which is given above. If needed I am willing to share the source code for the entire project as there is nothing special in it. It is attached with this mail. I would like this group's help on the fact as to why the app force closes when the GPS is turned on and how do I fix it. The app does not use the GPS at all. First, your overlay's location data member will be null sometimes, the way this is written. getLastKnownLocation() can return null at any time, and in that case, you don't have a Location to work with. You will need to either add intelligence to the overlay to handle this case, or not set up the overlay until you have a Location. Second, you are using GPS, the way this is written. More specifically, you are using the Criteria system, which will return GPS as a possible provider. Given your specific Criteria setup, if GPS is available, it probably is the best provider. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Android Training...At Your Office: http://commonsware.com/training -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Raghav Sood http://www.raghavsood.com/ http://www.androidappcheck.com/ http://www.telstop.tel/ -- Raghav Sood http://www.raghavsood.com/ http://www.androidappcheck.com/ http://www.telstop.tel/ -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Puzzling crash report. Location app doesn't work if the GPS is on
On Thu, Jul 7, 2011 at 9:43 AM, Raghav Sood raghavs...@gmail.com wrote: Coming back to the point. Is there any way to make sure that the app does not use GPS? That is even if GPS is on the app only uses the cell network? The whole point of my app was to provide the location without the GPS being used. Can I set the provider of the location? Don't use Criteria. Use LocationManager.NETWORK_PROVIDER. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Android Training...At Your Office: http://commonsware.com/training -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Puzzling crash report. Location app doesn't work if the GPS is on
On Thu, Jul 7, 2011 at 8:47 AM, Mark Murphy mmur...@commonsware.com wrote: Don't use Criteria. Use LocationManager.NETWORK_PROVIDER. To add to this, this is because by using Criteria and, more importantly, specifying ACCURACY_FINE and POWER_HIGH, you are pretty much saying gimme GPS if available. - TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered devices -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Puzzling crash report. Location app doesn't work if the GPS is on
Thanks Mark, TreKing and Filip. The problems gone away and will not be coming back. LocationManager.NETWORK_PROVIDER works like a charm. Thanks On Thu, Jul 7, 2011 at 7:32 PM, TreKing treking...@gmail.com wrote: On Thu, Jul 7, 2011 at 8:47 AM, Mark Murphy mmur...@commonsware.comwrote: Don't use Criteria. Use LocationManager.NETWORK_PROVIDER. To add to this, this is because by using Criteria and, more importantly, specifying ACCURACY_FINE and POWER_HIGH, you are pretty much saying gimme GPS if available. - TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered devices -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Raghav Sood http://www.raghavsood.com/ http://www.androidappcheck.com/ http://www.telstop.tel/ -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en