Hi,
I get
** Service (pushservice) Start **
java.lang.SecurityException: Not allowed to start service Intent { act=com.google.android.c2dm.intent.REGISTER (has extras) } without permission com.google.android.c2dm.permission.RECEIVE
This is my code, taken from the example https://www.b4x.com/android/forum/t...otification-gcm-framework-and-tutorial.19226/
What am I doing wrong? I changed nothing but the sender-ID, which I got from Google.
I get
** Service (pushservice) Start **
java.lang.SecurityException: Not allowed to start service Intent { act=com.google.android.c2dm.intent.REGISTER (has extras) } without permission com.google.android.c2dm.permission.RECEIVE
This is my code, taken from the example https://www.b4x.com/android/forum/t...otification-gcm-framework-and-tutorial.19226/
B4X:
Sub RegisterDevice (Unregister As Boolean)
Dim i As Intent
If Unregister Then
i.Initialize("com.google.android.c2dm.intent.UNREGISTER", "")
Else
i.Initialize("com.google.android.c2dm.intent.REGISTER", "")
Log (Main.senderid)
' the senderid is valid
i.PutExtra("sender", Main.SenderId)
End If
Dim r As Reflector
Dim i2 As Intent
i2 = r.CreateObject("android.content.Intent")
Dim pi As Object
pi = r.RunStaticMethod("android.app.PendingIntent", "getBroadcast", _
Array As Object(r.GetContext, 0, i2, 0), _
Array As String("android.content.Context", "java.lang.int", "android.content.Intent", "java.lang.int"))
i.PutExtra("app", pi)
Log ("startservice")
StartService(i)
Log ("started")
' the program comes here
End Sub
Sub HandleRegistrationResult(Intent As Intent)
' this point is never reached
If Intent.HasExtra("error") Then
Log("Error: " & Intent.GetExtra("error"))
ToastMessageShow("Error: " & Intent.GetExtra("error"), True)
Else If Intent.HasExtra("unregistered") Then
If hcInit = False Then hc.Initialize("hc")
Dim req As HttpRequest
' xxx
' req.InitializeGet(Main.BoardUrl & "?device_password=" & Main.DeviceBoardPassword & _
' "&name=" & Main.DeviceName & "&id=") 'Empty id is sent here. This will cause the board to delete this name.
' hc.Execute(req, UnregisterTask)
Else If Intent.HasExtra("registration_id") Then
If hcInit = False Then hc.Initialize("hc")
Dim rid As String
rid = Intent.GetExtra("registration_id")
Dim req As HttpRequest
' req.InitializeGet(Main.BoardUrl & "?device_password=" & Main.DeviceBoardPassword & _
' "&name=" & Main.DeviceName & "&id=" & rid)
' hc.Execute(req, RegisterTask)
End If
End Sub
What am I doing wrong? I changed nothing but the sender-ID, which I got from Google.