Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Button button = (Button) findViewById(R.id.button1);
- final EditText editText = (EditText) findViewById(R.id.editText1);
- button.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- final Timer timer = new Timer();
- timer.scheduleAtFixedRate(new TimerTask() {
- @Override
- public void run() {
- Calendar c = Calendar.getInstance();
- int seconds = c.get(Calendar.SECOND);
- final String time = String.valueOf(seconds);
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- editText.setText(time);
- if (time.equals("10")) {
- Uri link = Uri.parse("http://www.hosttimer.com");
- Intent intent = new Intent(Intent.ACTION_VIEW, link);
- startActivity(intent);
- timer.cancel();
- }
- }
- });
- }
- }, 0, 1000);
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement