Android Tutorial Android push notification (C2DM) framework and tutorial

donnyy

Member
Licensed User
Longtime User
yes, i did. I basically used the files from the zip file, then follow your instructions and make the changes using your sample files. The only thing i did that is not in your instructions is, I added reflexion to the library, and then compile it, and then i got the error message.
 

donnyy

Member
Licensed User
Longtime User
Sorry Erel, i just realized i was trying to test the push notification with my old file, which doesn't have pushservice module. However, after i added the module and then tried it again, i got the following message instead:

java.lang.RuntimeException: Unable to start service com.dispatch.test.pushservice@47c1f908 with Intent { act= cmp=com.dispatch.test/.pushservice (has extras) }: java.lang.RuntimeException: 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

Does this mean google hasn't accepted my app yet? But i did get an email back from Google after i registered my app.
 

donnyy

Member
Licensed User
Longtime User
Hi Erel, I have figured it out, it was my manifest, it got overwritten when i compiled the program. Now everything works. Thanks
 

donnyy

Member
Licensed User
Longtime User
Hi Erel, I have another question, this is kind of out of the scope of your software, I hope you can point me to the right direction. I have tried to send a message from my Linux server using your c2dm (I have the php and jar files copied over), but when I execute the command, I got the following error:

java.lang.RuntimeException: Unknown method: %*
at anywheresoftware.b4a.c2dm.C2DM.main(C2DM.java:234)

Do you know what the right syntax is for Linux in the batch file?

Thanks for your help.
 

donnyy

Member
Licensed User
Longtime User
Erel, sorry to be a pain. I got another question, when i execute the command in linux command line, the message i got is just the first word of the message, even though i have put quotes on the message. Any idea how i can do this please?
 

donnyy

Member
Licensed User
Longtime User
Erel, I have it figured out. Running the command on Linux with 'send' will only send the first word, but if I put the message in a file and then use sendtextfile to send the message, it will send the whole message. Thanks for all your help and your wonderful script.
 

donnyy

Member
Licensed User
Longtime User
Hi Erel,

I have another question with the push notification, in the pushservice program, instead of using the toastmessageshow, is it possible to use a msgbox to display the message instead? I have tried changing it to a msgbox but it comes up with the following error:

android.view.WindowManager$BadTokenException: Unable to add window — token null is not for an application

Looks like it is because of the dialog box, is it because the pushservice is running in the background?

Thanks
 

salmander

Active Member
Licensed User
Longtime User
You cannot use a msgbox in a service. Msgbox can only be used in Activities. However,you can use a process global variable to assign the pushed message value to it and then display a msgbox in the activity, showing the value of the variable.
 

donnyy

Member
Licensed User
Longtime User
Thanks Salmander. I will give it a try, I am still a newbie to this software.
 

donnyy

Member
Licensed User
Longtime User
H Salmander, just wondering if you can help me again. I have changed my program to use CallSub to Main to pop-up a message box, and it worked. However, it is not showing the message, this is what i have set up in Main:

Sub Process_Globals
Dim NewMsg As String

Sub ShowNewMessage
Msgbox(NewMsg,"New Message arrived")
End Sub

In PushService, I have this in Sub MessageArrived:

ToastMessageShow("New message: " & Data, True)
NewMsg = Data
CallSub(Main,"ShowNewMessage")

Am I doing this wrong? The toast message shows up but not the NewMsg

Thanks.
 

donnyy

Member
Licensed User
Longtime User
I have figured it out, i need to change NewMsg to Main.NewMsg in order to reference the variable I initialized in Main.
 

donnyy

Member
Licensed User
Longtime User
i have downloaded your file and tried to run it, it came back with a google permission error when i tried to register. When you register c2dm with google, did you get an email from google?
 

dealsmonkey

Active Member
Licensed User
Longtime User
i have downloaded your file and tried to run it, it came back with a google permission error when i tried to register. When you register c2dm with google, did you get an email from google?

I signed up to C2DM just after it went public. I took approx 48 hours to get an email confirming access, not sure how long it takes now though sorry.
 

rfresh

Well-Known Member
Licensed User
Longtime User
Am I able to send a msg to one specific device? Or do I have to send a msg to all devices using my app?

Thanks...
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…