本文整理汇总了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();
}