You have probably solved this by now. But telling you you shouldn't do it seemed like no answer to me. Obviously if the ping command doesn't exist you can't call it and you can handle the error. But if it does, wow!
Here is a way to do it. Works on the emulator 2.1 anyway. The emulator likes to be started after you have a good Internet connection though. If you start the emulator and change your connection somehow, it may not work after that. I didn't need any permissions to do it either on the emulator.
public class Rooted extends Activity {
EditText body;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
body = (EditText)findViewById(R.id.bodyEditText);
try {
Process process = Runtime.getRuntime().exec("/system/bin/ping -c 1 betterpaving.com");
BufferedReader reader = new BufferedReader(
new InputStreamReader(process.getInputStream()));
int i;
char[] buffer = new char[4096];
StringBuffer output = new StringBuffer();
while ((i = reader.read(buffer)) > 0) output.append(buffer, 0, i);
reader.close();
body.append(output.toString()+"\n");
}
catch (IOException e) {
body.append("Error\n");
e.printStackTrace();
}
}//oncreate
//TODO: Fill In Methods Etc.
//"ping -c 1 betterpaving.com" try this sometime
}//class
It's different from yours anyway and needs to be put somewhere besides the create block, but...