-1

The app will breakdown when t.stop(); situation: I want to save the textview text to array every 2s(25times);

t = new Thread() {
    public void run() {
        try {
            while (!isInterrupted()) {
                Thread.sleep(2000);
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        // update TextView here!
                        if (i < 25) {
                            mypDialog.setProgress(i * 4);
                            getRssi(iBeaconPosition, i);
                            i++;
                        } else {
                            finishCalibration();
                        }
                    }
                });
            }
        } catch (InterruptedException e) {
        }
    }
};
t.start();
Gary Chen
  • 248
  • 2
  • 14
Ben Luk
  • 735
  • 2
  • 8
  • 15

1 Answers1

1

You have to use:

t.interrupt();

For more information read this link and this link;

Community
  • 1
  • 1