tag:blogger.com,1999:blog-9106822915308030165.post1172552868995046456..comments2023-10-19T03:44:12.128-07:00Comments on devtcg: Push services: Implementing persistent mobile TCP connectionsAnonymoushttp://www.blogger.com/profile/02055635184861046754noreply@blogger.comBlogger15125tag:blogger.com,1999:blog-9106822915308030165.post-72481323425849243792012-08-22T18:02:49.558-07:002012-08-22T18:02:49.558-07:00@Erdal, yes the System.currentTimeMillis() approac...@Erdal, yes the System.currentTimeMillis() approach should not be used. You're correct that SystemClock.elapsedRealTime() is the appropriate replacement.<br /><br />Also, re using this approach with HttpClient: there's actually no need. A properly configured HttpClient instance will re-use idle connections. The easiest way to do this safely is to use a static instance of your HttpClient along with the HttpClient#execute(HttpUriRequest, ResponseHandler) method. ResponseHandler is a convenient variant of execute that will ensure the stream is appropriately managed and released back into the pool of idle connections. Avoid calling HttpUriRequest#abort() unless you truly wish to close the underlying connection.Anonymoushttps://www.blogger.com/profile/02055635184861046754noreply@blogger.comtag:blogger.com,1999:blog-9106822915308030165.post-44966691608028859222011-02-14T13:19:40.091-08:002011-02-14T13:19:40.091-08:00I noticed the use of System.currentTimeMillis() fo...I noticed the use of System.currentTimeMillis() for scheduling the reconnects.<br /><br />Would it be safer to use SystemClock.elapsedRealTime() instead? because this does not get affected by timezones changing?<br /><br />Of course the alarm type would have to be changed to ELAPSED_REALTIME_WAKEUP.Erdalhttps://www.blogger.com/profile/15227258546490235001noreply@blogger.comtag:blogger.com,1999:blog-9106822915308030165.post-45164747027835123522011-01-27T01:59:56.630-08:002011-01-27T01:59:56.630-08:00Hi Josh,
Sometimes on the KeepAliveService I get ...Hi Josh,<br /><br />Sometimes on the KeepAliveService I get a random java.net.SocketException: The operation timed out. This happens on my Inputstream when it calls a read. I set a setSoTimeout to 30 mins like you suggested in the code but this timeout seems to be thrown much earlier.<br /><br />This is followed by the cleanup at the bottom that just says socket not connected. This is bad for my server which handles threads listening to the client as it does not even throw the EOFException to do the cleanup on the server side. Any ideas?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-9106822915308030165.post-41380223773547008022010-12-15T23:44:11.135-08:002010-12-15T23:44:11.135-08:00Would it be possible to use this persistent tcp so...Would it be possible to use this persistent tcp socket as the underlying socket for an HttpClient?Erdalhttps://www.blogger.com/profile/15227258546490235001noreply@blogger.comtag:blogger.com,1999:blog-9106822915308030165.post-35098171558537453272010-12-02T16:41:37.242-08:002010-12-02T16:41:37.242-08:00@NickD, nothing special is required to wake up to ...@NickD, nothing special is required to wake up to retrieve I/O that is being waited upon. The system will ensure that if data is available on the socket the CPU will awake and your app will have the opportunity to read it.<br /><br />@Dave, I'm uncertain what could be wrong in your code but if you compile this sample program you will see that nothing special is required.Anonymoushttps://www.blogger.com/profile/02055635184861046754noreply@blogger.comtag:blogger.com,1999:blog-9106822915308030165.post-43417620316812164342010-07-25T08:48:41.982-07:002010-07-25T08:48:41.982-07:00Dave,
Did you ever resolve this? I'm curious...Dave,<br /><br />Did you ever resolve this? I'm curious because it seems one needs to do something to have the application thread be awake to handle the received dataUnknownhttps://www.blogger.com/profile/01924736088458081322noreply@blogger.comtag:blogger.com,1999:blog-9106822915308030165.post-73755708011743834582010-02-12T09:14:15.383-08:002010-02-12T09:14:15.383-08:00I am trying to implement a type of push service si...I am trying to implement a type of push service similar to IMAP using your example as a basis. What I have found is the ConnectionThread that is in the InputStream.read() loop never runs when the phone goes to sleep. You mentioned in your comments that there is no need to use a WakeLock. I'm either doing something wrong or missing something.<br /><br />Dave Arnold<br />Tacoma, WAUnknownhttps://www.blogger.com/profile/13998624995747537961noreply@blogger.comtag:blogger.com,1999:blog-9106822915308030165.post-34810153947412680142009-12-19T02:11:09.145-08:002009-12-19T02:11:09.145-08:00Great blog entry, really informative! I wonder tho...Great blog entry, really informative! I wonder though why google doesn't describe in more detail the way they push their gmails to the phone.tobsenhttps://www.blogger.com/profile/11139392387746884577noreply@blogger.comtag:blogger.com,1999:blog-9106822915308030165.post-81171067147662606052009-10-13T02:02:34.144-07:002009-10-13T02:02:34.144-07:00Hi!
i am facing an problem?
problem:
server (web ...Hi!<br />i am facing an problem?<br /><br />problem:<br />server (web server) wants to send data( or some information) to mobile client (android based phone).<br />means simply notify to start work, then mobile start working on specific application.<br /><br />i would like to do a SMS from server to mobile, to start working. buts its not the best idea.<br />as we can assign too an IP to android mobile phone in case of WiFi or USB connectivity.<br />but phone will use GPRS or GSM, so there is no unique IP of Mobile so that we can access mobile phone using Socket Programing<br />so there is any idea or tutorial for this mention problem.<br /><br />dont give the example that GMAIL, or black beryy etc using these technology, actually tell me how technically its work<br />thanks<br />waiting for your good repliesMohsinhttps://www.blogger.com/profile/17663768733995637938noreply@blogger.comtag:blogger.com,1999:blog-9106822915308030165.post-36015834294600141482009-09-10T13:08:47.961-07:002009-09-10T13:08:47.961-07:00I have implemented IMAP IDLE in K-9. Thanks for t...I have implemented IMAP IDLE in K-9. Thanks for the pointers on how to handle the persistent connections.<br /><br />It is not production release ready, but definitely works for receiving new mail via IMAP IDLE. I still need to handle the untagged FETCH messages to handle deletes and read status changes, and a few other cases.<br /><br />Please see Issue 4 in K-9's Google Code site for details. The work is ongoing in the /k9mail/branches/issue4-1.X branch.Danielhttps://www.blogger.com/profile/08133717973612191989noreply@blogger.comtag:blogger.com,1999:blog-9106822915308030165.post-60537734772702420282009-03-17T16:02:00.000-07:002009-03-17T16:02:00.000-07:00Daniel,You do not need to do any special work to w...Daniel,<BR/>You do not need to do any special work to wake up when data is received on the socket. Even while sleeping, the radio is periodically listening for network events. If it didn't do this, it wouldn't make a very good phone :)<BR/><BR/>You will not require a WakeLock.Anonymoushttps://www.blogger.com/profile/02055635184861046754noreply@blogger.comtag:blogger.com,1999:blog-9106822915308030165.post-43584387321003802142009-02-23T15:54:00.000-08:002009-02-23T15:54:00.000-08:00Chris,Using a WakeLock, like I added to DAmail and...Chris,<BR/>Using a WakeLock, like I added to DAmail and K-9 for use with checking email while asleep, would have a huge impact on battery life. If the G1 is kept on using a WakeLock for ever, to allow IMAP IDLE traffic to come through at any time, the phone would not run long enough to be useful. The hard part, indeed, is to support IMAP IDLE without using a 100% duty cycle WakeLock.<BR/><BR/>Dan.Danielhttps://www.blogger.com/profile/08133717973612191989noreply@blogger.comtag:blogger.com,1999:blog-9106822915308030165.post-67384628935407088562009-02-03T18:07:00.000-08:002009-02-03T18:07:00.000-08:00Daniel,It's possible to set a PARTIAL_WAKE_LOCK wi...Daniel,<BR/><BR/>It's possible to set a PARTIAL_WAKE_LOCK with PowerManager. http://code.google.com/android/reference/android/os/PowerManager.html<BR/><BR/>Although, I'm not sure of the effect it would have on battery.Chrishttps://www.blogger.com/profile/17688738925944301337noreply@blogger.comtag:blogger.com,1999:blog-9106822915308030165.post-52093937514964436332009-01-22T11:57:00.000-08:002009-01-22T11:57:00.000-08:00I can see how your method keeps the TCP/IP session...I can see how your method keeps the TCP/IP session alive, but does it let you get asynchronous incoming data from the socket if the phone goes to sleep? Meaning, once the phone sleeps, before your 28 minute wake-up timer, will your Service get woken up in order to handle incoming data?<BR/><BR/>I'm working on K-9 email, and am interested in the various approaches to checking IMAP servers for new mail.Danielhttps://www.blogger.com/profile/08133717973612191989noreply@blogger.comtag:blogger.com,1999:blog-9106822915308030165.post-42012890522693061392009-01-12T13:56:00.000-08:002009-01-12T13:56:00.000-08:00You comment that onDestroy is not called when your...You comment that onDestroy is not called when your Service is killed, and this is completely consistent with the Service lifecycle. You can <B>not</B> count on onDestory being called for anything. You <B>can</B> count on onStop being called. For a service you should consider it dead after it returns from onStop. For an Activity you should consider it dead after onPause is called.<BR/><BR/>Cheers,<BR/>Justin<BR/>Android Team @ GoogleUnknownhttps://www.blogger.com/profile/06525864153501296717noreply@blogger.com