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 run a background process and do *not* wait?

Here is verified example for Python REPL: >>> import subprocess >>> import sys >>> p = subprocess.Popen([sys.executable, ‘-c’, ‘import time; time.sleep(100)’], stdout=subprocess.PIPE, stderr=subprocess.STDOUT); print(‘finished’) finished How to verify that via another terminal window: $ ps aux | grep python Output: user 32820 0.0 0.0 2447684 3972 s003 S+ 10:11PM 0:00.01 /Users/user/venv/bin/python -c import time; time.sleep(100)

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

How Nike+ GPS on iPhone receives accelerometer updates in the background?

For the sake of providing an answer to this question, even though it is already self answered… “If you use the newer Core Motion API, you can receive updates in the background.” Here is an example: – (void)startAccelerationCollection { [self.motionManager startAccelerometerUpdatesToQueue:[[NSOperationQueue alloc] init] withHandler:^(CMAccelerometerData *data, NSError *error) { dispatch_async(dispatch_get_main_queue(), ^{ [self.accelerometerReadings addObject:data]; }); }]; }