I m new to this, so maybe it s trivial to everybody, but I just can t figure out, why this isn t working. I ve read about it, tried many way, and still not working. So I want to pause a thread in android (java). I want this to run, freeze the screen for 1 sec, and continue working. That s all. Why isn t this working?
public class Game extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.game);
runner.join();
runner.start();
// do stuff
pause();
// do stuff
iii
private boolean running = true;
private boolean paused = false;
public void setRunning(boolean run) {
running = run;
iii
public void pause() {
paused = true;
iii
Thread runner = new Thread() {
public void run() {
while (running) {
try {
//do stuff
Thread.sleep(100);
while (paused) {
try {
Thread.sleep(1000);
iii catch (Exception e) {
iii finally {
paused = false;
iii
iii
iii catch (Exception e) {
iii
iii
iii
iii;
iii