2
Is there any way to show the average ping on android? I saw some tutorials but the most I could was the following:
public void fExecutarPing(View view){
List<String> listaResponstaPing = new ArrayList<String>();
ArrayAdapter<String> adapterLista = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,
listaResponstaPing);
try {
String cmdPing = "ping -c 4 " + host;
Runtime r = Runtime.getRuntime();
Process p = r.exec(cmdPing);
BufferedReader in = new BufferedReader( new InputStreamReader(p.getInputStream()));
String inputLinhe;
while((inputLinhe = in.readLine())!= null){
listaResponstaPing.add(inputLinhe);
//adiciona para cada linha
listaPing.setAdapter(adapterLista);
}
} catch (Exception e) {
Toast.makeText(this, "Erro: "+e.getMessage().toString(), Toast.LENGTH_SHORT).show();
}
}
That shows the ping, along with the rest of the information. And what I need is for you to show only the ping average. How to do?
Oops, I’ll test it here.
– Marceloawq
didn’t work. I tried to pass
pacotesrecebidos
for a textview and yet nothing is displayed– Marceloawq
How did it go? Can you debug or log to see?
– Thiago Luiz Domacoski
W/System.err: java.lang.StringIndexOutOfBoundsException: length=0; regionStart=19; regionLength=-20
– Marceloawq
See if the text has revived? Can display full text?
– Thiago Luiz Domacoski