mpao
7/15/2016 - 6:48 AM

Simula una operazione in background per progressbar

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
            }
        });
    }
}