Various technical articles, IT-related tutorials, software information, and development journals
Friday, August 16, 2019
LocalBroadcastManager sendBroadcastSync crashes if a null receiver was registered
Today I saw another developer experience a NullPointerException inside sendBroadcastSync on a LocalBroadcastManager. The manager wasn't null, but it turned out some other part of the application had called registerReceiver passing a null reference. So when Android tried to deliver the intent, it tried to call a method on that null it had stored. I'm not sure of a good way to investigate this in a large codebase, but in Robolectric tests a shadow could be written that fails immediately if passed a null broadcast receiver.
Labels:
android
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment