コード例 #1
0
  /* Starts timer service and notification */
  private void startSleepTimer(long duration) {
    // start timer service
    if (mSleepTimerService == null) {
      mSleepTimerService = new SleepTimerService();
    }
    mSleepTimerService.startActionStart(mActivity, duration);

    // show timer notification
    showSleepTimerNotification(duration);
    mSleepTimerRunning = true;
    LogHelper.v(LOG_TAG, "Starting timer service and notification.");
  }
コード例 #2
0
 /* Stops timer service and notification */
 private void stopSleepTimer() {
   // stop timer service
   if (mSleepTimerService != null) {
     mSleepTimerService.startActionStop(mActivity);
   }
   // cancel notification
   if (mSleepTimerNotification != null && mSleepTimerNotification.isShown()) {
     mSleepTimerNotification.dismiss();
   }
   mSleepTimerRunning = false;
   LogHelper.v(LOG_TAG, "Stopping timer service and notification.");
   Toast.makeText(
           mActivity,
           mActivity.getString(R.string.toastmessage_timer_cancelled),
           Toast.LENGTH_SHORT)
       .show();
 }