Reputation: 395
I've one thread, but i'd like to wait for it to finish before continue with the next actions. How could i do it?
new Thread(
new Runnable() {
@Override
public void run() {
mensaje = getFilesFromUrl(value);
}
}).start();
here i'd like to put something (but loops) that knows when thread finishes and evaluate the result (mensaje)
btnOk.setVisibility(View.VISIBLE);
progressBar.setVisibility(View.GONE);
lblEstado.setText(mensaje);
if(mensaje.equals("Importado"))
startActivity(new Intent(ScanUrl.this, MainActivity.class));
Upvotes: 36
Views: 47846
Reputation: 9711
Thread t = new Thread(new Runnable() {
@Override
public void run() {
mensaje = getFilesFromUrl(value);
}});
t.start(); // spawn thread
t.join(); // wait for thread to finish
Upvotes: 70