當前位置: 首頁>>代碼示例>>Java>>正文


Java CountDownTimer.start方法代碼示例

本文整理匯總了Java中android.os.CountDownTimer.start方法的典型用法代碼示例。如果您正苦於以下問題:Java CountDownTimer.start方法的具體用法?Java CountDownTimer.start怎麽用?Java CountDownTimer.start使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.os.CountDownTimer的用法示例。


在下文中一共展示了CountDownTimer.start方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: resumeRecording

import android.os.CountDownTimer; //導入方法依賴的package包/類
protected void resumeRecording() {
    if (paused) {
        paused = false;
        timer = new CountDownTimer(milisUntilFinished, 100) {
            @Override
            public void onTick(long millisUntilFinished) {
                handleClockTick(millisUntilFinished);
                DCDashboardFragment.this.milisUntilFinished = millisUntilFinished;
            }

            @Override
            public void onFinish() {
                stopRecording();
            }
        };
        timer.start();
        updateView();
    }
}
 
開發者ID:Dentacoin,項目名稱:aftercare-app-android,代碼行數:20,代碼來源:DCDashboardFragment.java

示例2: onStartCommand

import android.os.CountDownTimer; //導入方法依賴的package包/類
@Override
  public int onStartCommand(Intent intent, int flags, int startId) {

// 第一個參數是總時間, 第二個參數是間隔
      mCodeTimer = new CountDownTimer(129000, 1000) {
          @Override
          public void onTick(long millisUntilFinished) {
		// 廣播剩餘時間
              broadcastUpdate(IN_RUNNING, millisUntilFinished / 1000 + "");
          }

          @Override
          public void onFinish() {
		// 廣播倒計時結束
              broadcastUpdate(END_RUNNING);
              // 停止服務
              stopSelf();
          }
      };
// 開始倒計時
      mCodeTimer.start();
      return super.onStartCommand(intent, flags, startId);
  }
 
開發者ID:stytooldex,項目名稱:stynico,代碼行數:24,代碼來源:Reg.java

示例3: onStartCommand

import android.os.CountDownTimer; //導入方法依賴的package包/類
@Override
  public int onStartCommand(Intent intent, int flags, int startId) {

// 第一個參數是總時間, 第二個參數是間隔
      mCodeTimer = new CountDownTimer(60000, 1000) {
          @Override
          public void onTick(long millisUntilFinished) {
		// 廣播剩餘時間
              broadcastUpdate(IN_RUNNING, millisUntilFinished / 1000 + "");
          }

          @Override
          public void onFinish() {
		// 廣播倒計時結束
              broadcastUpdate(END_RUNNING);
              // 停止服務
              stopSelf();
          }
      };
// 開始倒計時
      mCodeTimer.start();
      return super.onStartCommand(intent, flags, startId);
  }
 
開發者ID:stytooldex,項目名稱:stynico,代碼行數:24,代碼來源:msf_shell.java

示例4: start

import android.os.CountDownTimer; //導入方法依賴的package包/類
@Override
public boolean start(Object obj) {
	try{
		mSensorManger = (SensorManager)getmServiceContext().getSystemService(Context.SENSOR_SERVICE);
		mSensor = mSensorManger.getDefaultSensor(Sensor.TYPE_PROXIMITY);
		mSensorListener = new MySensorListener();
		request(AntiTheftService.REQUEST_SHOW_MSG, getName() + "防護已開啟,將在10秒後正式生效" + SF.TIP);
		mCDTimer = new CountDownTimer(10000, 1000) {
			
			@Override
			public void onTick(long millisUntilFinished) {
			}
			
			@Override
			public void onFinish() {
				mSensorManger.registerListener(mSensorListener, mSensor, SensorManager.SENSOR_DELAY_NORMAL);
			}
		};
		setNeedDelay(true);
		mCDTimer.start();
		return true;
	}catch(Exception e){
		request(AntiTheftService.REQUEST_SHOW_MSG, "開啟\"" + getName() + "\"防護失敗,可能您的設備不支持距離傳感器!");
		return false;
	}
}
 
開發者ID:SShineTeam,項目名稱:Huochexing12306,代碼行數:27,代碼來源:PocketProtector.java

示例5: startCountDownTimer

import android.os.CountDownTimer; //導入方法依賴的package包/類
public void startCountDownTimer(final Intent intent) {
    long timeLeftInMillis = TimerManager.getInstance(this).getTimeLeftInMillis();
    CountDownTimer countDownTimer = new CountDownTimer(timeLeftInMillis, 1000) {

        @Override
        public void onTick(long millisUntilFinished) {
            intent.putExtra(Constants.Timer.KEY_COUNTDOWN, millisUntilFinished);
            getApplicationContext().sendBroadcast(intent);
        }

        @Override
        public void onFinish() {
            showCountDownNotification();
            removeDayInTime();
        }
    };

    if(timeLeftInMillis > 1000){
        countDownTimer.start();
        Log.d(TAG, "startCountDownTimer: CountDownStarted");
    }
}
 
開發者ID:adityakamble49,項目名稱:gofun-app,代碼行數:23,代碼來源:CountDownService.java

示例6: goToHome

import android.os.CountDownTimer; //導入方法依賴的package包/類
private void goToHome() {
    timer = new CountDownTimer(500, 100) {
        @Override
        public void onTick(long millisUntilFinished) {

        }

        @Override
        public void onFinish() {
            startActivity(new Intent(SplashActivity.this, HomeActivity.class));
            overridePendingTransition(0, R.anim.fade_out);
            finish();
        }
    };

    timer.start();
}
 
開發者ID:mayuroks,項目名稱:Coin-Tracker,代碼行數:18,代碼來源:SplashActivity.java

示例7: trackToastLength

import android.os.CountDownTimer; //導入方法依賴的package包/類
/**
 * Starts a {@link CountDownTimer} which counts down from the length of the StyleableToastListener
 * from the moment {@link StyleableToast#show()} is called to cancel and reset the animation at end of the {@link StyleableToast}'s length.
 */
public void trackToastLength() {
    CountDownTimer countDownTimer = new CountDownTimer(length + EXTRA_DELAY, 1000) {
        @Override
        public void onTick(long millisUntilFinished) {
        }

        @Override
        public void onFinish() {
            if (onToastFinishedListener != null) {
                onToastFinishedListener.onToastFinished();
            }
        }
    };
    countDownTimer.start();
}
 
開發者ID:Muddz,項目名稱:StyleableToast,代碼行數:20,代碼來源:ToastLengthTracker.java

示例8: initTimer

import android.os.CountDownTimer; //導入方法依賴的package包/類
private void initTimer() {
    timer = new CountDownTimer(TIMER_LENGTH, 1000) {
        @Override
        public void onTick(long millisUntilFinished) {
            //int countdown = (int)(millisUntilFinished / 1000);
            //setDlgTitle(getContext().getString(R.string.save_to_title)
            //+ " (" + String.valueOf(countdown) +")");
            refreshUI(millisUntilFinished);
        }

        @Override
        public void onFinish() {
            dismiss();
        }
    };
    timer.start();
}
 
開發者ID:WorldBank-Transport,項目名稱:RoadLab-Pro,代碼行數:18,代碼來源:SaveMeasurementToDialog.java

示例9: onCreate

import android.os.CountDownTimer; //導入方法依賴的package包/類
@Override
public void onCreate() {
    super.onCreate();

    Log.i(TAG, "Starting timer...");
    if(NsdChatActivity.mUserChoice.equals("client"))
        timer = ContestRules.timer;
    else
        timer = ContestUpload.millSecs;
    countDownTimer = new CountDownTimer(timer, 1000) {
        @Override
        public void onTick(long millisUntilFinished) {
            broadcastIntent.putExtra("countdown", millisUntilFinished);
            sendBroadcast(broadcastIntent);
            Log.i(TAG, "Countdown seconds remaining: " + millisUntilFinished / 1000);
        }
        @Override
        public void onFinish() {
            broadcastIntent.putExtra("countdown", 0L);
            sendBroadcast(broadcastIntent);
            Log.i(TAG, "Timer finished");
        }
    };

    countDownTimer.start();
}
 
開發者ID:suchoX,項目名稱:Simplify,代碼行數:27,代碼來源:TimerBroadcastService.java

示例10: initViewsAndEvents

import android.os.CountDownTimer; //導入方法依賴的package包/類
@Override
protected void initViewsAndEvents() {
    int index = (int) (Math.random() * imgs.length);

    ivBg.setImageResource(imgs[index]);

    timer = new CountDownTimer(3500, 1000) {
        @Override
        public void onTick(long millisUntilFinished) {
            tvSkip.setText(String.format(getResources().getString(R.string.skip), (int) (millisUntilFinished / 1000 + 0.1)));
        }

        @Override
        public void onFinish() {
            tvSkip.setText(String.format(getResources().getString(R.string.skip), 0));
            startActivity(new Intent(mContext, HomeActivity.class));
            finish();
        }
    };
    timer.start();
}
 
開發者ID:smuyyh,項目名稱:SprintNBA,代碼行數:22,代碼來源:SplashActivity.java

示例11: countdown

import android.os.CountDownTimer; //導入方法依賴的package包/類
private void countdown() {
    mTimer = new CountDownTimer(60000, 1000) {
        @Override
        public void onTick(long l) {
            mTime.setText("Your SMS should arrive in " + l / 1000 + "second");
        }

        @Override
        public void onFinish() {
            mTime.setText("Resend SMS code");
            mTime.setEnabled(true);
            mTime.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    SMSManager.sendRequestCode(CheckSMSActivity.this, mPhoneNamber);
                }
            });
        }
    };
    mTimer.start();
}
 
開發者ID:bluedai180,項目名稱:XiangZiShen,代碼行數:22,代碼來源:CheckSMSActivity.java

示例12: startCountDownTime

import android.os.CountDownTimer; //導入方法依賴的package包/類
private void startCountDownTime(long time) {
    timer = new CountDownTimer(time * 1000, 1000) {
        @Override
        public void onTick(long millisUntilFinished) {
            //每隔countDownInterval秒會回調一次onTick()方法
            down_timer.setText(String.format(getString(R.string.count_down_str), millisUntilFinished / 1000));
        }

        @Override
        public void onFinish() {
            openDemo();
        }

    };
    timer.start();// 開始計時
}
 
開發者ID:WFC-LinkedME,項目名稱:LinkedME-Android-Deep-Linking-Demo,代碼行數:17,代碼來源:WelcomeActivity.java

示例13: startCountDownTime

import android.os.CountDownTimer; //導入方法依賴的package包/類
private void startCountDownTime(long time) {
    timer = new CountDownTimer(time * 1000, 1000) {
        @Override
        public void onTick(long millisUntilFinished) {
            //每隔countDownInterval秒會回調一次onTick()方法
            down_timer.setText(String.format(getString(R.string.count_down_str), millisUntilFinished / 1000));
        }

        @Override
        public void onFinish() {
            // TODO: 27/02/2017 廣告演示:廣告展示完畢需要調用該方法執行深度鏈接跳轉
            closeActivity();
        }

    };
    timer.start();// 開始計時
}
 
開發者ID:WFC-LinkedME,項目名稱:LinkedME-Android-Deep-Linking-Demo,代碼行數:18,代碼來源:AdvertisementActivity.java

示例14: countDownTime

import android.os.CountDownTimer; //導入方法依賴的package包/類
private void countDownTime() {
    final CountDownTimer timer = new CountDownTimer(TimeUnit.SECONDS.toMillis(30),
            TimeUnit.SECONDS.toMillis(1)) {
        @SuppressLint("DefaultLocale")
        @Override
        public void onTick(long millisUntilFinished) {
            verifyCodeBtn.setText(String.format("%d秒", millisUntilFinished / 1000));
        }

        @Override
        public void onFinish() {
            verifyCodeBtn.setEnabled(true);
            verifyCodeBtn.setText(getResources().getString(R.string.verify_code));
        }
    };
    timer.start();
}
 
開發者ID:oxoooo,項目名稱:excited-android,代碼行數:18,代碼來源:LoginActivity.java

示例15: setTimer

import android.os.CountDownTimer; //導入方法依賴的package包/類
/**
 * 設置時間並開始記時
 * @param time 毫秒級
 * @param tag
 */
public synchronized <T> void setTimer(final long time, long countDownInterval, final T tag) {
    cancel();
    if (time <= 0) {
        return;
    }
    mTimer = new CountDownTimer(time, countDownInterval) {
        @Override
        public void onTick(long millisUntilFinished) {
            if (timeFormat != null) {
                setText(timeFormat.formtDownTime(millisUntilFinished));
            }
        }

        @Override
        public void onFinish() {
            if (onTickStopListener != null) {
                onTickStopListener.onTickStop(tag);
            }
        }
    };
    mTimer.start();
}
 
開發者ID:ymex,項目名稱:kits,代碼行數:28,代碼來源:TickTimeTextView.java


注:本文中的android.os.CountDownTimer.start方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。