I want to set the time only for 10 minutes .Whenever at the time of finish / Complete the 10 mins immediately my Buttons are disable and pop up the message. I have start the timer on button event and stop on also button event. But I want to start the time when my new Activity is start and my all buttons and textview is disable when free/finish the 10 min automatically. And display the popup message. How to do this?

Here is my code.

The xml file

```
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#000000" >

    <TextView
        android:id="@+id/timerValue"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/pauseButton"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="37dp"
        android:text="@string/timerVal"
        android:textColor="#ffffff"
        android:textSize="40sp" />

    <Button
        android:id="@+id/startButton"
        android:layout_width="90dp"
        android:layout_height="45dp"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"
        android:layout_marginLeft="38dp"
        android:text="@string/startButtonLabel" />

    <Button
        android:id="@+id/pauseButton"
        android:layout_width="90dp"
        android:layout_height="45dp"
        android:layout_alignBaseline="@+id/startButton"
        android:layout_alignBottom="@+id/startButton"
        android:layout_alignParentRight="true"
        android:layout_marginRight="38dp"
        android:text="@string/pauseButtonLabel" />

</RelativeLayout>

```

The Activity Code

```
public class TimerDemo extends Activity
{

    private Button startButton;
    private Button pauseButton;

    private TextView timerValue;
    private long startTime = 0L;
    private Handler customHandler = new Handler();

    long timeInMilliseconds = 0L;
    long timeSwapBuff = 0L;
    long updatedTime = 0L;

    @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.demo_one);

        timerValue = (TextView) findViewById(R.id.timerValue);

        startButton = (Button) findViewById(R.id.startButton);

        startButton.setOnClickListener(new View.OnClickListener() 
        {

            public void onClick(View view)
            {

                startTime = SystemClock.uptimeMillis();

                customHandler.postDelayed(updateTimerThread, 0);

            }

        });

        pauseButton = (Button) findViewById(R.id.pauseButton);

        pauseButton.setOnClickListener(new View.OnClickListener()
        {

            public void onClick(View view) 
            {

                timeSwapBuff += timeInMilliseconds;

                customHandler.removeCallbacks(updateTimerThread);

            }

        });

    }

    private Runnable updateTimerThread = new Runnable() 
    {

        public void run()
        {

            timeInMilliseconds = SystemClock.uptimeMillis() - startTime;

            updatedTime = timeSwapBuff + timeInMilliseconds;

            int secs = (int) (updatedTime / 1000);

            int mins = secs / 60;

            secs = secs % 60;

            int milliseconds = (int) (updatedTime % 1000);

            timerValue.setText("" + mins + ":"

            + String.format("%02d", secs) + ":"

            + String.format("%03d", milliseconds));

            customHandler.postDelayed(this, 0);

        }

    };

}

```