Android Question Problem with Google Cloud Message

Harris

Expert
Licensed User
Longtime User
I set, in the Erel example, this code for GCM:

#Region Module Attributes
#StartAtBoot: true
#End Region


Here is the code that handles the new in-coming message from the Push Service Module (modified):

Code: Copy
Sub MessageArrived (Intent As Intent)
    Dim From, CollapseKey, Data As String 'ignore
    If Intent.HasExtra("from") Then From = Intent.GetExtra("from")
    If Intent.HasExtra("data") Then Data = Intent.GetExtra("data")
    If Intent.HasExtra("collapse_key") Then CollapseKey = Intent.GetExtra("collapse_key")

    'Here you should handle the new message:
    Log("New message arrived: " & Data)
    'ToastMessageShow("New message: " & Data, True)
    StartActivity(Main)

    Main.messg = Data
    Main.SQL1.ExecNonQuery2("INSERT INTO mess_in (time_in, from_user,mess_text,read_it) VALUES(?,?,?,?)", Array As Object(DateTime.Now,"Johnny",Data,0))
    Main.In_Out = 1
End Sub

As you can see, I take the new message and insert it into "mess_in". When the activity fires up - I will show (and speak) the newly arrived message (first in DESC order).

When I first turn on the device, and try to send a new message (depending soley on the service to handle things) I get Error: Unfortunately, "myapp" has stopped. Which means crash... I can see that one process and one service for "myapp" is running after a clean boot. After this error 0 process and 1 service is running.

If I start the activity (by manually selecting it) and send a message - all works fine???

Google N7 kitkat.
 
Will have a look and try again...
Thanks
 
Upvote 0
Yes, the call to SQL1 was wrapped in FirstTime. As you suggested, I moved init to a code module for all subs to use - also check to see if already init'ed. Removed the startatboot as well...

Client side works well. Now for My Server... Next Request.
 
Upvote 0
Back
Top