Last edited:
It will be much more complicated than using this framework.I'm going to try and find a push notification solution for tablets using the UDP protocol.
It will be much more complicated than using this framework.
The "sending program" is a java program. You can call it from PHP or any other language you want.
here you go mate. Follow this post.What about using TCP/IP to send the msg? Would that also be more complicated than using C2DM?
Hey mate,@Salamander
Thanks for that link. I did register with Google 2 days ago for a C2DM account and got a confirmation email that I am in but am still waiting for my ID to use C2DM.
I guess I'll have to use C2DM for my push notifications because Erel says that's the easiest way although it looks complicated to me at this point. I'll dig in (again) and see if I can get the sample code to work. But I will need my ID first from Google right?
You can create a service that polls your web server every x seconds. However it will consume a lot of battery (and you will need to maintain this web server).What about using TCP/IP to send the msg?
You are now ready to test it!
Run the B4A project, enter a name in the text field and press on the Register button. You should see a toast message saying Registration successful. Messages are also printed to the logs. It can take several seconds.
This means two things. Your device has registered with Google servers and also that the registration id was sent to the developer web service (currently configured with the service hosted here w) with the specified name.
The name will be used to reference the device. Note that each device must have a unique name.
The push framework is only for sending messages to devices. It doesn't allow the device to send messages back.Also how would you retreive info from the database on a server to a home or business computer when a user has sent info to the database?
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", "")
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)
StartService(i)
End Sub