Simula una operazione in background per progressbar
for (int i = 0; i < 100; i++) {
try {
Thread.sleep(50);
} catch (InterruptedException e) {
e.printStackTrace();
}
final int progress = i;
if (activity != null) {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
// show progress bar with progress value
}
});
}
}