Problem with GCM push while application is paused

170 views
Skip to first unread message

Michael Kroll

unread,
Dec 6, 2013, 5:09:15 AM12/6/13
to codenameone...@googlegroups.com
Hi!

I'm doing some testing with GCM at the moment and when I try to send the push notification while the application is minimized, it just crashes.
I did try it once more with the debuger running and found this in the logs:

I/GCM     (  899): GCM message com.thammit.pushtest 0:1386323743904455%e31617eff9fd7ecd
I/System.out(24875): Push message received: null
I/System.out(24875): Push type: null
I/System.out(24875): Is running: false
W/GCM/DMM (  899): broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE pkg=com.thammit.pushtest (has extras) }
D/AndroidRuntime(24875): Shutting down VM
W/dalvikvm(24875): threadid=1: thread exiting with uncaught exception (group=0x4154eb90)
E/AndroidRuntime(24875): FATAL EXCEPTION: main
E/AndroidRuntime(24875): Process: com.thammit.pushtest, PID: 24875
E/AndroidRuntime(24875): java.lang.RuntimeException: Unable to start receiver com.thammit.pushtest.PushReceiver: java.lang.NullPointerException
E/AndroidRuntime(24875):        at android.app.ActivityThread.handleReceiver(ActivityThread.java:2407)
E/AndroidRuntime(24875):        at android.app.ActivityThread.access$1600(ActivityThread.java:135)
E/AndroidRuntime(24875):        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1473)
E/AndroidRuntime(24875):        at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(24875):        at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(24875):        at android.app.ActivityThread.main(ActivityThread.java:4998)
E/AndroidRuntime(24875):        at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(24875):        at java.lang.reflect.Method.invoke(Method.java:515)
E/AndroidRuntime(24875):        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
E/AndroidRuntime(24875):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
E/AndroidRuntime(24875):        at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(24875): Caused by: java.lang.NullPointerException
E/AndroidRuntime(24875):        at java.nio.charset.ModifiedUtf8.countBytes(ModifiedUtf8.java:75)
E/AndroidRuntime(24875):        at java.nio.charset.ModifiedUtf8.encode(ModifiedUtf8.java:119)
E/AndroidRuntime(24875):        at java.io.DataOutputStream.writeUTF(DataOutputStream.java:197)
E/AndroidRuntime(24875):        at com.codename1.impl.android.AndroidImplementation.appendNotification(AndroidImplementation.java:303)
E/AndroidRuntime(24875):        at com.thammit.pushtest.PushReceiver.handleMessage(PushReceiver.java:126)
E/AndroidRuntime(24875):        at com.thammit.pushtest.PushReceiver.onReceive(PushReceiver.java:55)
E/AndroidRuntime(24875):        at android.app.ActivityThread.handleReceiver(ActivityThread.java:2400)
E/AndroidRuntime(24875):        ... 10 more
W/ActivityManager(  585):   Force finishing activity com.thammit.pushtest/.ApplicationStub
D/ConnectivityService(  585): handleInetConditionHoldEnd: net=1, condition=100, published condition=100

Everything seems to work fine if the app is running.

I call this to show the notification in the statusbar:
public void push(String value) {
     Display.getInstance().notifyStatusBar("Push erfolgreich", "Push erhalten", "Test", false, false, null);
}


I also have questions about push:

I'm using JSON to contact the gcm Server and have to pass my payload like this:
"data":
      {
          "hello":"world",
      }

But the value string is alway null/empty and I can't find another way to get my payload.

And what actually goes into the hashtable you can give to notifyStatusbar?

Thanks.

Shai Almog

unread,
Dec 6, 2013, 3:12:04 PM12/6/13
to codenameone...@googlegroups.com
Hi,
you need to use our push servers to send the data since we rely on some meta data passed there to route the message correctly.
See http://www.codenameone.com/3/post/2013/07/pushing-it.html

Otherwise things just won't work in various ways and collide with our code that does a lot of this work for you.
Reply all
Reply to author
Forward
0 new messages