Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Yes it is possible, you could e.g. implement such connections in a <a href="http://developer.android.com/guide/components/services.html" rel="nofollow">Service</a>, which runs even if your application is not running. If required, you could also request permissions to prevent the device/CPU from sleeping (e.g. <a href="http://developer.android.com/reference/android/Manifest.permission.html#WAKE_LOCK" rel="nofollow">WAKE_LOCk</a>).</p> <p>What kind of connection you then use (via <a href="http://developer.android.com/reference/java/net/HttpURLConnection.html" rel="nofollow">HttpUrlConnection</a> or Apache HttpClient, GET, POST etc.) is up to you and your needs. However, pay special attention to this warning in the docs:</p> <blockquote> <p><strong>Caution</strong>: A service runs in the main thread of its hosting process—the service does not create its own thread and does not run in a separate process (unless you specify otherwise). This means that, if your service is going to do any CPU intensive work or blocking operations (such as MP3 playback or networking), you should create a new thread within the service to do that work.</p> </blockquote> <p>If timeouts are an issue, you might need to set those to infinite values, e.g. with <code>setReadTimeout(0)</code> (<a href="http://developer.android.com/reference/java/net/URLConnection.html#setReadTimeout%28int%29" rel="nofollow">docs</a>, although connections shouldn't time-out by default) or other timeout-configurations.</p> <p>Also keep in mind that long running (networking) operations can <strong>drain the battery</strong> really fast.</p>
    singulars
    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. 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