title: Push message causes crash when app is not running
body: <p>I have  google GCM implemented as native and works fine when the app is actively running on the foreground. However, if the app is not running after some long idle time, when a push message comes in, though it is detected, causes a crash. I dont have a class PushReceiver.java so this must be injected by CN1. Here is the stack trace:</p>
  
  <pre><code>02-14 22:50:14.796: W/System.err(21026): java.io.EOFException
  02-14 22:50:14.796: W/System.err(21026):    at libcore.io.Streams.readFully(Streams.java:83)
  02-14 22:50:14.796: W/System.err(21026):    at java.io.DataInputStream.readFully(DataInputStream.java:99)
  02-14 22:50:14.796: W/System.err(21026):    at java.io.DataInputStream.decodeUTF(DataInputStream.java:178)
  02-14 22:50:14.796: W/System.err(21026):    at java.io.DataInputStream.decodeUTF(DataInputStream.java:173)
  02-14 22:50:14.796: W/System.err(21026):    at java.io.DataInputStream.readUTF(DataInputStream.java:169)
  02-14 22:50:14.796: W/System.err(21026):    at com.codename1.impl.android.AndroidImplementation.getPendingPush(AndroidImplementation.java:381)
  02-14 22:50:14.796: W/System.err(21026):    at com.rixma.mobile.PushReceiver.handleMessage(PushReceiver.java:162)
  02-14 22:50:14.796: W/System.err(21026):    at com.rixma.mobile.PushReceiver.onReceive(PushReceiver.java:62)
  02-14 22:50:14.796: W/System.err(21026):    at android.app.ActivityThread.handleReceiver(ActivityThread.java:3011)
  02-14 22:50:14.796: W/System.err(21026):    at android.app.ActivityThread.access$1800(ActivityThread.java:177)
  02-14 22:50:14.796: W/System.err(21026):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1507)
  02-14 22:50:14.796: W/System.err(21026):    at android.os.Handler.dispatchMessage(Handler.java:102)
  02-14 22:50:14.796: W/System.err(21026):    at android.os.Looper.loop(Looper.java:135)
  02-14 22:50:14.796: W/System.err(21026):    at android.app.ActivityThread.main(ActivityThread.java:5910)
  02-14 22:50:14.796: W/System.err(21026):    at java.lang.reflect.Method.invoke(Native Method)
  02-14 22:50:14.806: W/System.err(21026):    at java.lang.reflect.Method.invoke(Method.java:372)
  02-14 22:50:14.806: W/System.err(21026):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1405)
  02-14 22:50:14.806: W/System.err(21026):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1200)
  02-14 22:50:14.806: D/AndroidRuntime(21026): Shutting down VM
  02-14 22:50:14.806: E/AndroidRuntime(21026): FATAL EXCEPTION: main
  02-14 22:50:14.806: E/AndroidRuntime(21026): Process: com.rixma.mobile, PID: 21026
  02-14 22:50:14.806: E/AndroidRuntime(21026): java.lang.RuntimeException: Unable to start receiver com.rixma.mobile.PushReceiver: java.lang.NullPointerException: Attempt to get length of null array
  02-14 22:50:14.806: E/AndroidRuntime(21026):    at android.app.ActivityThread.handleReceiver(ActivityThread.java:3018)
  02-14 22:50:14.806: E/AndroidRuntime(21026):    at android.app.ActivityThread.access$1800(ActivityThread.java:177)
  02-14 22:50:14.806: E/AndroidRuntime(21026):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1507)
  02-14 22:50:14.806: E/AndroidRuntime(21026):    at android.os.Handler.dispatchMessage(Handler.java:102)
  02-14 22:50:14.806: E/AndroidRuntime(21026):    at android.os.Looper.loop(Looper.java:135)
  02-14 22:50:14.806: E/AndroidRuntime(21026):    at android.app.ActivityThread.main(ActivityThread.java:5910)
  02-14 22:50:14.806: E/AndroidRuntime(21026):    at java.lang.reflect.Method.invoke(Native Method)
  02-14 22:50:14.806: E/AndroidRuntime(21026):    at java.lang.reflect.Method.invoke(Method.java:372)
  02-14 22:50:14.806: E/AndroidRuntime(21026):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1405)
  02-14 22:50:14.806: E/AndroidRuntime(21026):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1200)
  02-14 22:50:14.806: E/AndroidRuntime(21026): Caused by: java.lang.NullPointerException: Attempt to get length of null array
  02-14 22:50:14.806: E/AndroidRuntime(21026):    at com.rixma.mobile.PushReceiver.handleMessage(PushReceiver.java:163)
  02-14 22:50:14.806: E/AndroidRuntime(21026):    at com.rixma.mobile.PushReceiver.onReceive(PushReceiver.java:62)
  02-14 22:50:14.806: E/AndroidRuntime(21026):    at android.app.ActivityThread.handleReceiver(ActivityThread.java:3011)
  02-14 22:50:14.806: E/AndroidRuntime(21026):    ... 9 more
  </code></pre>
  
  <p>Please advice how to work around this as it seems i do not have any control over the crashing code, it seems to be happening in CN1 code. I am supposed to use such push notifications to wake up a 'dead' app, as long as it was not forcefully stopped by user.</p>