how to close activity after x minutes?
<p>I am looking for simplest way to close opened activity after x minutes. Does android provide countdown class or do I have to made one by my self ?</p>

<p>I've tried this code but its not working</p>

<pre><code>Thread isOnDisplayThread = new Thread(new Runnable() {
            @Override
            public void run() {
                Timer mTimer = new Timer();
                mTimer.schedule(new TimerTask() {    
                    @Override
                    public void run() {
                        Log.d(TAG, (isApplicationOnDisplay) ? "Application on display" : "APPLICATION ON BACKGROUND");

                        if (!isApplicationOnDisplay) {
                            notOnDisplayTime++;
                            if (notOnDisplayTime &gt;= 10) {

                                Process.killProcess(Process.myPid());
                            }
                        } else {
                            notOnDisplayTime = 0;
                        }
                    }
                }, 0, 1000);
            }
        });

        isOnDisplayThread.run();
</code></pre>
