Skip to content

Instantly share code, notes, and snippets.

@scalone
Created July 2, 2013 14:51
Show Gist options
  • Save scalone/5909958 to your computer and use it in GitHub Desktop.
Save scalone/5909958 to your computer and use it in GitHub Desktop.
def onCreate(bundle)
super
@handler = Handler.new;
@i = 0
@thread = Thread.new do
@i += 1
puts "#{@i}"
@handler.postDelayed(self, 1000)
#or @handler.postDelayed(@thread, 1000)
end
end
def onResume
super
@handler.removeCallbacks(@thread);
@handler.postDelayed(@thread, 0);
end
def onPause
super
@handler.removeCallbacks(@thread);
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment