We don't provide complete code from here. You can use CountDownTimer.
CountDownTimer timer = new CountDownTimer(15 *60 * 1000, 1000) {
public void onTick(long millisUntilFinished) {
}
public void onFinish() {
}
};
When user has stopped any action use timer.start() and when user does the action do timer.cancel().