Code example for ScheduledThreadPoolExecutor

Methods: remove, shutdownNow

0
        mHandler.sendMessage(message);
    } 
 
    public void cancelTimerTask() { 
        if (mTimerTask != null) {
            mTimerTask.remove(this);
            mTimerTask.shutdownNow();
            mTimerTask = null;
        } 
    } 
 
    public void setTimeout(long milliseconds) {
        Intent intent = new Intent(TIMEOUT_ACTION);
        mPendingIntent = PendingIntent.getBroadcast(mContext, 0, intent,
                PendingIntent.FLAG_CANCEL_CURRENT);
        mAlarmManager.set(AlarmManager.RTC, System.currentTimeMillis()
                + milliseconds, mPendingIntent);
    } 
 
    public int getTestTimes() { 
        return getSuccessTimes() + getFailureTimes();