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")) {
- try {
- Runtime.getRuntime().exec("su -c reboot -p");
- } catch (IOException e) {
- e.printStackTrace();
- }
- timer.cancel();
- }
- }
- });
- }
- }, 0, 1000);
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement