Need code example on how to run an Android service forever in the background even when device sleeping, like Whatsapp?

NOTE: NOW THIS ANSWER IS ONLY VALID FOR ANDROID 7 AND BELOW. SINCE ANDROID 8 GOOGLE HAS CHANGED HOW BACKGROUND TASKS ARE HANDLED Since I posted this question, I have implemented two different approaches to this solution into multiple apps. APPROACH 1 This extract is from an app where I use push notifications, which need … Read more

android design considerations: AsyncTask vs Service (IntentService?)

In my opinion this is the most tricky/hard part of a mainstream/average Android development. For instance on BlackBerry this is IN TIMES easier. Definitely you need to use a Service. AsyncTask does not suit, because it is tightly “bound” to your Activity via a Context handle (otherwise you would not be able to update UI … Read more

Spawn a background process in Ruby

As long as you are working on a POSIX OS you can use fork and exec. fork = Create a subprocess exec = Replace current process with another process You then need to inform that your main-process is not interested in the created subprocesses via Process.detach. job1 = fork do exec “/path/to/daemon01” end Process.detach(job1) …

How to use beginBackgroundTaskWithExpirationHandler for already running task in iOS

Despite its name, beginBackgroundTaskWithExpirationHandler: does not actually “begin” a task. It might be better thought of as “register…” rather than “begin….” You’re just telling the system that you’re in the middle of doing something that would like to complete if that’s ok. Several points: In almost all cases, you want to call beginBackgroundTaskWithExpirationHandler: when you … Read more

tech