Urgent - Hard crash on Android when coming out of sleep

I’m getting this:

12-03 15:20:26.070: E/AndroidRuntime(32647): java.lang.NullPointerException

12-03 15:20:26.070: E/AndroidRuntime(32647): at com.ansca.corona.CoronaView.sendEvent(CoronaView.java:229)

12-03 15:20:26.070: E/AndroidRuntime(32647): at com.ansca.corona.CoronaView.sendEvent(CoronaView.java:214)

when my Android tablet running Android 3.1 comes out of sleep while running my CoronaCards application.  Because I don’t have access to the CoronaView source code, I can’t debug this.

Corona dev help please?

Alex

This is with CoronaCards 2014.2511

Are you calling CoronaView.destory() anywhere in your code?  If so you can make sure that its not called before you call sendEvent?  Also can you please send along some sample code?  Thanks.

Yes, I am calling CoronaView.destroy() in the onDestroy() routine of the housing Activity.

I think what is probably going on is that there might be times when coming out of sleep that the CoronaEnvironment isn’t yet ready and I try to call sendEvent().  What would be a lot better than crashing is for sendEvent() to return a boolean that tells me if the event was able to be sent, so that I can handle the case when the CoronaEnvironment might be unready.

So destroy was called before you called sendEvent()?

No, not really. As you know, in the normal activity lifecycle of an Android app, an activity can be stopped or even destroyed, then restarted and/or created multiple times.  In my case, when my activity is destroyed, I call CoronaView.destroy().  Then, when my activity is recreated, I recreate a new CoronaView and events are sent using that. But I don’t think I’m calling sendEvent on a CoronaView that is already destroyed. 

Actually, there is a chance that one of my timers might call sendEvent() after destroy() is called. I will try instrumenting my code to see if that is happening. In any case though, the more checking the sendEvent() code can do, the better, since the last thing I want is for my app to crash, and without having access to the CoronaCards source, it’s really hard to tell what is going on, especially since there is a history of sendEvent() crashing in a multithreaded environment.

This is with CoronaCards 2014.2511

Are you calling CoronaView.destory() anywhere in your code?  If so you can make sure that its not called before you call sendEvent?  Also can you please send along some sample code?  Thanks.

Yes, I am calling CoronaView.destroy() in the onDestroy() routine of the housing Activity.

I think what is probably going on is that there might be times when coming out of sleep that the CoronaEnvironment isn’t yet ready and I try to call sendEvent().  What would be a lot better than crashing is for sendEvent() to return a boolean that tells me if the event was able to be sent, so that I can handle the case when the CoronaEnvironment might be unready.

So destroy was called before you called sendEvent()?

No, not really. As you know, in the normal activity lifecycle of an Android app, an activity can be stopped or even destroyed, then restarted and/or created multiple times.  In my case, when my activity is destroyed, I call CoronaView.destroy().  Then, when my activity is recreated, I recreate a new CoronaView and events are sent using that. But I don’t think I’m calling sendEvent on a CoronaView that is already destroyed. 

Actually, there is a chance that one of my timers might call sendEvent() after destroy() is called. I will try instrumenting my code to see if that is happening. In any case though, the more checking the sendEvent() code can do, the better, since the last thing I want is for my app to crash, and without having access to the CoronaCards source, it’s really hard to tell what is going on, especially since there is a history of sendEvent() crashing in a multithreaded environment.