Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I am working on a similar application that runs a service that establishes a persistent TCP connection to a server upon launch in order to be able to receive messages from the server. The service does not acquire any locks. This part of the application has been implemented a while ago, and so far I haven't had any problems with not being able to receive messages from the server. After reading your question I decided to test why I wasn't having this problem.</p> <p>I thought that even if I am not holding any locks, maybe there are other applications that are, which therefore keep the CPU alive. Running <code>adb shell dumpsys</code>, I noticed that this wasn't the case: <code>mLocks.size=0</code>.</p> <p>This must mean that the application is still able to receive packets, even if the device is asleep. I could not find anything official on this, but several posts on the internet seem to agree:</p> <blockquote> <p>Although I haven’t found a good example of where this is documented, it seems that even if your phone is asleep, if data is received on the connection, your code will be woken up [...] (<a href="http://dalelane.co.uk/blog/?p=1599" rel="nofollow">source</a>)</p> </blockquote> <hr> <blockquote> <p>> Say that the device is in deep sleep and the network stack receives an incoming packet. Will that wake the device up?</p> <p>It should. (<a href="https://groups.google.com/forum/?fromgroups#!topic/android-platform/xTU1UeckGcM" rel="nofollow">source</a>)</p> </blockquote> <p>However, note that both sources recommend that you should acquire a wake lock to process the packets, in order to prevent the device from falling asleep during this processing. I don't do that in my application (maybe I should), but my processing is really short.</p> <p>When you say that your requests are not reaching your application, are you sure that they aren't? Maybe they are, but your application falls asleep before it can send a reply? Try acquiring the wake lock when you receive data on your socket and releasing it after you are done with your processing.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload