title: Call method before tab get switch in viewpager
body: <p>I am creating a sample app. I have a <code>TestActivity</code>. Inside this there are subject tabs like <code>SubjectTab1</code> and <code>SubjectTab2</code>. Each subject tab contain some questions. What i need to do is when i click on  <code>SubjectTab2</code> i need to save time spent on <code>SubjectTab1</code>. So on which event should i call this time spent method? </p>
  
  <p>here is SaveTimeSpent method</p>
  
  <pre><code>public  void SaveTimeSpentOnQue(int queNumber)
  {
      if(countDownTimer!=null)
      {
           countDownTimer.cancel();
           countDownTimer=null;
      }
  
   try {
          lstQuestionTimer=new ArrayList&lt;QuestionList&gt;();
          lstQuestionTimer=QuestionListDao.queryBuilder().where().eq("Number", queNumber)
                                          .and().eq("StudentTestRefrenceID", StudentTestRefrenceID) 
                                          .and().eq("SubjectId", SubjectId).query();
  
          if(lstQuestionTimer.size()&gt;0)
          {
              for (QuestionList ql : lstQuestionTimer)
              {
                  ql.setQueTimeSpent(TestTabFragment.strQueTimeSpent);
                  QuestionListDao.update(ql);
              }
          }
  
          System.out.println("Question Time Spent=============="+TestTabFragment.strQueTimeSpent);
  
      } catch (SQLException e) {
          e.printStackTrace();
      }
  }
  </code></pre>