ayoola-solomon / mytracks

Automatically exported from code.google.com/p/mytracks
0 stars 0 forks source link

NullPointerException in MapActivity.onOptionsItemSelected #741

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
The stack trace of this crash:
v1.1.13
java.lang.NullPointerException
at com.google.android.apps.mytracks.MapActivity.onOptionsItemSelected(MT:466)
at android.app.Activity.onMenuItemSelected(Activity.java:2208)
at com.google.android.apps.mytracks.MapActivity.onMenuItemSelected(MT:439)
at 
com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java
:755)
at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:143)
at 
com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:85
5)
at com.android.internal.view.menu.IconMenuView.invokeItem(IconMenuView.java:532)
at 
com.android.internal.view.menu.IconMenuItemView.performClick(IconMenuItemView.ja
va:122)
at android.view.View$PerformClick.run(View.java:9080)
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:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
at dalvik.system.NativeStart.main(Native Method)

v1.1.12
java.lang.NullPointerException
at com.google.android.apps.mytracks.MapActivity.onOptionsItemSelected(MT:467)
at android.app.Activity.onMenuItemSelected(Activity.java:2205)
at com.google.android.apps.mytracks.MapActivity.onMenuItemSelected(MT:440)
at 
com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java
:748)
at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:143)
at 
com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:85
5)
at com.android.internal.view.menu.IconMenuView.invokeItem(IconMenuView.java:532)
at 
com.android.internal.view.menu.IconMenuItemView.performClick(IconMenuItemView.ja
va:122)
at android.view.View$PerformClick.run(View.java:9210)
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:3701)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:862)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
at dalvik.system.NativeStart.main(Native Method)

Error code line:
...
line465:      case Constants.MENU_MY_LOCATION: {
line466:        dataHub.forceUpdateLocation();
...

The dataHub is initialized in onResume(),  whether such code will be executed 
when dataHub is null?

What steps will reproduce the problem?
1.
2.
3.

Original issue reported on code.google.com by youtaol@google.com on 30 Dec 2011 at 12:19

GoogleCodeExporter commented 8 years ago
This is because the menu item, MENU_MY_LOCATION, can be invoked after onPause 
is called. We just need to check against null for dataHub. I will prepare a CL 
for you to review.

Original comment by jshih@google.com on 6 Apr 2012 at 12:45

GoogleCodeExporter commented 8 years ago
Hi Youtao:

Wondering if you can review this CL.
http://code.google.com/r/jshih-mytracks9/source/detail?r=ced02798ce03fc005cd64f5
36137929d81196067#

Original comment by jshih@google.com on 6 Apr 2012 at 12:52

GoogleCodeExporter commented 8 years ago
How to reproduce that?

Original comment by youtaol@google.com on 6 Apr 2012 at 9:28

GoogleCodeExporter commented 8 years ago
You can try clicking on menu->"My Location" and then quickly switching to 
either the chart view or the stats view. 

Basically, dataHub is set to null by the onPause method. OnPause can happen 
when switching view, has an incoming call, etc. The UI action like clicking on 
"My Location" is asynchronous, which can easily happen after the onPause method.

Original comment by jshih@google.com on 9 Apr 2012 at 6:10

GoogleCodeExporter commented 8 years ago
Thanks, in such situation, this change should be good.

Original comment by youtaol@google.com on 10 Apr 2012 at 2:40

GoogleCodeExporter commented 8 years ago

Original comment by jshih@google.com on 11 Apr 2012 at 3:04