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