本文整理匯總了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();
}
}
示例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);
}
示例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);
}
示例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;
}
}
示例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");
}
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();// 開始計時
}
示例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();// 開始計時
}
示例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();
}
示例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();
}