Run shell script in background process no matter what activity in foreground? I have a shell script that looks does the following:

# /mnt/sdcard/touch.sh
sleep 10

while [ 1 ]; do
    input swipe 700 380 1020 600 1000
    input tap 960 540
    input swipe 1220 700 900 480 1000
    input tap 960 540
    input swipe 1220 700 900 480 1000
    input tap 960 540
    input swipe 700 380 1020 600 1000
    input tap 960 540
done


If I execute it from Terminal IDE (a terminal emulator), it only works while Terminal IDE is in the foreground, so I thought I'd make an actual app to execute it and keep it running in the background. Here's what I've got now:

package com.mycompany.myapp;

import android.app.*;
import android.os.*;
import android.view.*;
import android.widget.*;
import java.io.*;

public class MainActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        try {
            // RIGHT HERE. WHY DOES NOTHING HAPPEN?
            Runtime.getRuntime().exec(new String[]{"/system/bin/sh", "/mnt/sdcard/touch.sh", });
        }
        catch (IOException e) {/*...*/}
    }
}


But it doesn't do anything.

So how would I execute this, then leave it running in the background so that the taps and swipes happen while another app is in the foreground? You get the idea. :D
It worked by just doing sh /mnt/sdcard/touch.sh &amp; after having started a shell with adb shell. Then, when I closed the terminal forcibly while the process was in the background, the process remained running in the background of my phone as expected. I was able to kill the process later by getting with adb shell the using ps to find the process ID and kill -s KILL &lt;ID&gt; to kill it.

Basically, turns out I didn't have to make an Android app just to make my script run in the background. Clash on...