Hi,
I have a service to receive GCM-Messages. Is there a solution for catching the message when the user locks the screen of his phone (like WhatstUp) ? I have always tried two ways:
1) the B4A-GCM-documentation
2) the Broadcast library
Both doesn't give a signal when the new message comes in while the screen is locked. I that moment I unlock the screen (much later), the stored messages will be shown.
I have tried this both variants (change TRUE with FALSE to change the method):
I have a service to receive GCM-Messages. Is there a solution for catching the message when the user locks the screen of his phone (like WhatstUp) ? I have always tried two ways:
1) the B4A-GCM-documentation
2) the Broadcast library
Both doesn't give a signal when the new message comes in while the screen is locked. I that moment I unlock the screen (much later), the stored messages will be shown.
I have tried this both variants (change TRUE with FALSE to change the method):
B4X:
Sub Service_Create
If True Then
Broadcast.Initialize("BroadcastReceiver")
Else
Notification1.Initialize
Notification1.Icon = "icon" 'use the application icon file for the notification
Notification1.Vibrate = False
End If
End Sub
Sub Service_Start (StartingIntent As Intent)
If True Then
Broadcast.addAction("com.google.android.c2dm.intent.RECEIVE")
Broadcast.SetPriority(999)
Broadcast.registerReceiver("")
Else
Select StartingIntent.Action
Case "com.google.android.c2dm.intent.REGISTRATION"
HandleRegistrationResult(StartingIntent)
Case "com.google.android.c2dm.intent.RECEIVE"
MessageArrived(StartingIntent)
End Select
Notification1.SetInfo("ELS Servide", "Service ist gestartet", Main)
Notification1.Sound = False
Service.StartForeground(1, Notification1)
End If
End Sub
Sub BroadcastReceiver_OnReceive (Action As String, i As Object)
Dim i2 As Intent
i2=i
Log(i2.ExtrasToString)
MessageArrived(i2)
End Sub