Android Tutorial Android push notification (C2DM) framework and tutorial

rfresh

Well-Known Member
Licensed User
Longtime User
What's the interface to send out the msg? I assume this is some kind of web page? Do I have to create it or is this at Google's website and I have to login to send the msg? Thank you...
 

grant1842

Active Member
Licensed User
Longtime User
Erel has coded up a batch file to pass commands to a .jar file in the Desktop Folder.
This is the example provided in this tutorial.
 

rfresh

Well-Known Member
Licensed User
Longtime User
That wouldn't work for me. I would be sending cmds from my website using PHP. I think for me, trying to use C2DM is beyond my B4A programming skills.

I'm going to try and find a push notification solution for tablets using the UDP protocol. Thanks for your comment.
 

rfresh

Well-Known Member
Licensed User
Longtime User
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.

What about using TCP/IP to send the msg? Would that also be more complicated than using C2DM?
 

rfresh

Well-Known Member
Licensed User
Longtime User
@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?
 

salmander

Active Member
Licensed User
Longtime User
Hey mate,

I don't understand what Google ID you are talking about? You register with Google C2DM over here. You enter all the necessary details, for e.g: your package name and email address that you will be using for c2dm services. Then you wait for the google confirmation email. The email is basically an auto respond, which doesn’t contain anything specific. It just says that your C2DM should start working within 48 hours. Then, you just get on with the coding. I know, it does sound complicated at the beginning, but after a while, it all starts making sense. What helped me, is I kept on referring Erel's example code. And then you just have to make sense of the code.... I hope this post helps.

Good Luck.
 

rfresh

Well-Known Member
Licensed User
Longtime User
I moved this question into a new thread.
 
Last edited:

wl

Well-Known Member
Licensed User
Longtime User
Push through TCP connection

Hello,

I'm currently working on a push system using a C# application server-side.

You can have your Android app using a permanently open TCP connection (so you really have push instead of polling). I have the impression it does not really drain that battery fast (I have a keep-alive byte every few minutes).

I did some tests in the past. Polling every few minutes consumes a lot more battery (especially if you would be using HTTP or other existing protocol which has a lot of overhead).
 

Smee

Well-Known Member
Licensed User
Longtime User
I am reading this tutorial and trying to get my heads around it all and i have a couple of questions



Am I right in assuming that in a real world program you would probably use the deviceID or similar instead of allowing a user to enter a name in a text field?

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?
 

rfresh

Well-Known Member
Licensed User
Longtime User
I have a question about the sample Sub code below.

What does the i in StartService(i) represent? I see the Main and the PushService modules but I don't see an 'i' service module? What is the i argument in that ServiceStart() call?

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", "")
      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
 

rfresh

Well-Known Member
Licensed User
Longtime User
In my app I have a service called 'FTP'. So that service is not being used by C2DM service?

The reason I ask is that my service module 'FTP', it's StartServiceAt() suddenly stopped working when I added the C2DM code to my app. C2DM works but I'm wondering if it's stepping on my StartServiceAt() call in my own service module?
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…