Java 类android.os.CountDownTimer 实例源码
项目:aftercare-app-android
文件:DCDashboardFragment.java
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();
}
}
项目:stynico
文件:Reg.java
@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);
}
项目:stynico
文件:msf_shell.java
@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);
}
项目:pokequest
文件:PokeQuizActivity.java
/**
* init countdown timer
*
* @param timeSeconds total time in seconds to countdown
*/
void initCountDownTimer(int timeSeconds) {
mCountDownTimer = new CountDownTimer(timeSeconds * 1000 + 100, 1000) {
@Override
public void onTick(long millisUntilFinished) {
mTvTimer.setText(Long.toString(millisUntilFinished / 1000));
}
@Override
public void onFinish() {
mTvTimer.setText("0");
mCurPokeQuiz.finishQuestion();
showResult(R.string.quiz_result_timeout);
}
};
}
项目:WeiXinRecordedDemo
文件:MediaRecorderBase.java
/**
* 测试PreviewFrame回调次数,时间1分钟
*
*/
public void testPreviewFrameCallCount() {
new CountDownTimer(1 * 60 * 1000, 1000) {
@Override
public void onTick(long millisUntilFinished) {
Log.e("[Vitamio Recorder]", "testFrameRate..." + mPreviewFrameCallCount);
mPreviewFrameCallCount = 0;
}
@Override
public void onFinish() {
}
}.start();
}
项目:WeiXinRecordedDemo
文件:MediaRecorderBase.java
/**
* 测试PreviewFrame回调次数,时间1分钟
*
*/
public void testPreviewFrameCallCount() {
new CountDownTimer(1 * 60 * 1000, 1000) {
@Override
public void onTick(long millisUntilFinished) {
Log.e("[Vitamio Recorder]", "testFrameRate..." + mPreviewFrameCallCount);
mPreviewFrameCallCount = 0;
}
@Override
public void onFinish() {
}
}.start();
}
项目:Edu
文件:TimerView.java
public void startTimer(){
if(!isBegin){
isBegin = true;
timerview.setBackground(getResources().getDrawable(R.drawable.shape_bo_grey_cccccc_r4dp));
timerview.setTextColor(ColorStateList.valueOf(ContextCompat.getColor(getContext(),R.color.grey_cccccc)));
new CountDownTimer(60000, 1000) {
@Override
public void onTick(long millisUntilFinished) {
timerview.setText(millisUntilFinished/1000 + "s");
}
@Override
public void onFinish() {
timerview.setBackground(getResources().getDrawable(R.drawable.shape_bo_white_r4dp));
timerview.setTextColor(ColorStateList.valueOf(ContextCompat.getColor(getContext(),R.color.white)));
timerview.setText("获取验证码");
isBegin = false;
}
}.start();
}
}
项目:android-WearAccessibilityApp
文件:CircledImageViewPreference.java
public void setLoadingCircledImageView() {
mCircledImageText.setText(R.string.loading);
mCircledImage.setImageResource(R.drawable.stop);
mCircledImage.setCircleBorderColor(mColorAccent);
mCountDownTimer =
new CountDownTimer(10000, 10) {
@Override
public void onTick(long millisUntilFinished) {
float timeElapsed = (10000.0f - millisUntilFinished) / 10000.0f;
mCircledImage.setProgress(timeElapsed);
}
@Override
public void onFinish() {
setStartCircledImageView();
}
}.start();
}
项目:Hitalk
文件:DownTimer.java
/**
* [倒计为time长的时间,时间间隔为mills]
* @param time
* @param mills
*/
public void startDown(long time, long mills) {
mCountDownTimer = new CountDownTimer(time, mills) {
@Override
public void onTick(long millisUntilFinished) {
if (listener != null) {
listener.onTick(millisUntilFinished);
} else {
NLog.e(TAG, "DownTimerListener can not be null");
}
}
@Override
public void onFinish() {
if (listener != null) {
listener.onFinish();
} else {
NLog.e(TAG, "DownTimerListener can not be null");
}
if (mCountDownTimer != null)mCountDownTimer.cancel();
}
} .start();
}
项目:AIMSICDL
文件:Toaster.java
/**
* Long toast message
* TOAST_DURATION_MILLS controls the duration
* currently set to 6 seconds
* @param context Application Context
* @param msg Message to send
*/
public static void msgLong(final Context context, final String msg) {
if (context != null && msg != null) {
if (toast != null) {
toast.cancel();
}
new Handler(context.getMainLooper()).post(new Runnable() {
@Override
public void run() {
toast = Toast.makeText(context, msg, Toast.LENGTH_SHORT);
new CountDownTimer(Math.max(TOAST_DURATION_MILLS - SHORT_TOAST_DURATION, 1000), 1000) {
@Override
public void onFinish() {
toast.show();
}
@Override
public void onTick(long millisUntilFinished) {
toast.show();
}
}.start();
}
});
}
}
项目:AppsTimeline
文件:SplashActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
new CountDownTimer(1200, 1200) {
@Override
public void onTick(long l) {
}
@Override
public void onFinish() {
startActivity(new Intent(SplashActivity.this, MainActivity.class));
finish();
}
}.start();
}
项目:Hotspot-master-devp
文件:TimerUtils.java
/**
* 倒计时,不需要手动开启和结束,仅中途取消需要手动cancel
*
* @param millisInFuture
* 总时间
* @param countDownInterval
* 间隔时间
* @param timerListener
* 响应回调
* @return
*/
public static CountDownTimer getCountDownInstance(long millisInFuture,
long countDownInterval, final TimerListener timerListener) {
if (timerListener == null)
return null;
return new CountDownTimer(millisInFuture, countDownInterval) {
@Override
public void onTick(long millisUntilFinished) {
timerListener.onTimerUpdate(millisUntilFinished);
}
@Override
public void onFinish() {
timerListener.onTimerStop();
}
}.start();
}
项目:ChimpCheck
文件:CountdownFragment.java
public void startCounting(long cdtTime){
if(cdt != null){
cdt.cancel();
}
cdt = new CountDownTimer(cdtTime, 1000) {
@Override
public void onTick(long l) {
textCount.setText("seconds remaining: " + l / 1000);
}
@Override
public void onFinish() {
textCount.setText(getString(R.string.count_default));
}
}.start();
}
项目:lrs_android
文件:SimpleController.java
public void start() {
if (skip()) {
return;
}
//判断该类角色是否有幸存者
long time = new Random().nextInt((int) millisInFuture);
if (isCanRandom) {
if (time < 3000) {
time = 3000;
}
} else {
time = millisInFuture;
}
new CountDownTimer(time, COUNT_DOWN_INTERVAL) {
@Override
public void onTick(long millisUntilFinished) {
}
@Override
public void onFinish() {
runnable.run();
}
}.start();
}
项目:lrs_android
文件:GameActivity.java
private void doTimer(long time) {
if (timer != null) {
timer.cancel();
}
timer = new CountDownTimer(time, 1000) {
@Override
public void onTick(long millisUntilFinished) {
// day_v.setVisibility(View.VISIBLE);
// day_timer_tv.setText(millisUntilFinished / 1000 + " s");
DialogManager.showGameDay(GameActivity.this, myRole_v, null, null, millisUntilFinished / 1000 + " s");
}
@Override
public void onFinish() {
// day_v.setVisibility(View.GONE);
DialogManager.dismissDialog();
}
}.start();
}
项目:synesthesiavision
文件:ConnectBluetooth.java
private void startMain() {
new CountDownTimer(500, 500) {
@Override
public void onTick(long millisUntilFinished) {
Log.d("Timer", "Timer ok");
}
@Override
public void onFinish() {
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
startActivity(intent);
close();
}
}.start();
}
项目:MinimalismJotter
文件:SplashActivity.java
@Override
protected void onResume() {
super.onResume();
start();
new CountDownTimer(2000, 1000) {
@Override
public void onTick(long millisUntilFinished) {
}
@Override
public void onFinish() {
startActivity(new Intent(SplashActivity.this, NoteListActivity.class));
finish();
}
}.start();
}
项目:AndroidFFmpegCompress
文件:RecordView.java
/**
* 开始计时
*/
private void startTimeCount() {
endTimeCount();
mCountDownTimer = new CountDownTimer(maxDuration * 1000, 1000) {
@Override
public void onTick(long millisUntilFinished) {
if (null != mOnRecordCallback) {
mOnRecordCallback.onProgress(maxDuration, (int) (maxDuration - millisUntilFinished / 1000));
}
}
@Override
public void onFinish() {
if (null != mOnRecordCallback) {
mOnRecordCallback.onProgress(maxDuration, maxDuration);
mOnRecordCallback.onFinish();
}
stopRecord();
}
}.start();
}
项目:Huochexing12306
文件:PocketProtector.java
@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;
}
}
项目:Sega
文件:RegisterActivity.java
private void startCountdownTimer() {
countDownTimer = new CountDownTimer(120000, 1000) {
public void onTick(long millisUntilFinished) {
countdown.setText("Time remaining : " + millisUntilFinished / 1000);
}
public void onFinish() {
countdown.setText("Click here to resend sms verification");
countdown.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
registerUser(name, email, password, phone, address, area);;
}
});
}
}.start();
}
项目:BWS-Android
文件:AsynchronousBackgroundHandler.java
@Override
public int runWithDelay(@NonNull final Runnable runnable, @IntRange(from = 0) long delayInMillis) {
final int taskId = getTaskId(scheduledTasks);
CountDownTimer scheduledTask = new CountDownTimer(delayInMillis, delayInMillis) {
@Override
public void onTick(long l) {
// do nothing (is disabled anyway because "countDownInterval" is set to "millisInFuture")
}
@Override
public void onFinish() {
scheduledTasks.remove(taskId);
runnable.run();
}
}.start();
scheduledTasks.put(taskId, scheduledTask);
return taskId;
}
项目:photo-editor-android
文件:PhotoEditorActivity.java
private void returnBackWithSavedImage() {
updateView(View.GONE);
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
parentImageRelativeLayout.setLayoutParams(layoutParams);
new CountDownTimer(1000, 500) {
public void onTick(long millisUntilFinished) {
}
public void onFinish() {
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
String imageName = "IMG_" + timeStamp + ".jpg";
Intent returnIntent = new Intent();
returnIntent.putExtra("imagePath", photoEditorSDK.saveImage("PhotoEditorSDK", imageName));
setResult(Activity.RESULT_OK, returnIntent);
finish();
}
}.start();
}
项目:FantaF1
文件:LoginActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
Constant.activityState=0;
new CountDownTimer(2000, 1000) {
public void onTick(long millisUntilDone) { }
public void onFinish() {
loadPreferences();
if(Constant.fanta.length()>0){
startMainActivity();
Constant.activityState=1;
} else setContent();
}
}.start();
}
项目:FantaF1
文件:LoginActivity.java
private void setContent() {
setContentView(R.layout.activity_login);
screen = (RelativeLayout)findViewById(R.id.rl);
ColorDrawable[] color = {new ColorDrawable(getResources().getColor(R.color.colorAccent)), new ColorDrawable(getResources().getColor(R.color.colorPrimary)) };
TransitionDrawable trans = new TransitionDrawable(color);
screen.setBackgroundDrawable(trans);
trans.startTransition(1800);
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getString(R.string.default_web_client_id)).requestEmail().build();
mGoogleApiClient = new GoogleApiClient.Builder(getBaseContext())
.enableAutoManage(this, this) .addApi(Auth.GOOGLE_SIGN_IN_API, gso).build();
mAuth = FirebaseAuth.getInstance();
FirebaseDatabase database = FirebaseDatabase.getInstance();
root= database.getReference("room_names");
loadRooms();
new CountDownTimer(2500, 1000) {
public void onTick(long millisUntilDone) { }
public void onFinish() {
currentUser = mAuth.getCurrentUser();
updateUI(currentUser);
}
}.start();
}
项目:lecrec-android
文件:ActivityLaunchScreen.java
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FacebookSdk.sdkInitialize(getApplicationContext());
callbackManager = CallbackManager.Factory.create();
if(AppController.USER_ID != null && AppController.USER_TOKEN != null) {
new CountDownTimer(1000, 100) {
public void onTick(long millisUntilFinished) { }
public void onFinish() {
goActivityMain();
}
}.start();
} else {
changeToLoginView();
}
pref = getSharedPreferences(CONST.PREF_NAME, MODE_PRIVATE);
editor = pref.edit();
}
项目:lecrec-android
文件:ActivityRecordVoice.java
void initRxPlayer(){
mRxAudioPlayer.play(PlayConfig.file(mConvertedAudioFile).looping(false).leftVolume(0F).rightVolume(0F).build())
.subscribeOn(Schedulers.io())
.subscribe(new Action1<Boolean>() {
@Override
public void call(Boolean aBoolean) { }
});
new CountDownTimer(500, 100) {
public void onTick(long millisUntilFinished) { }
public void onFinish() {
if(mRxAudioPlayer.getMediaPlayer() != null) {
mRxAudioPlayer.getMediaPlayer().stop();
}
}
}.start();
}
项目:Hackathon_2017
文件:MainActivity.java
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
pregunta = findViewById(R.id.txt_pregunta);
r1 = findViewById(R.id.b1);
r2 = findViewById(R.id.b2);
r3 = findViewById(R.id.b3);
r4 = findViewById(R.id.b4);
new Peticion().execute();
new CountDownTimer(999999999, 1000){
@Override
public void onFinish() {
}
@Override
public void onTick(long l) {
new Posicion().execute();
}
}.start();
}
项目:gofun-app
文件:CountDownService.java
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");
}
}
项目:android-AutofillFramework
文件:WelcomeActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.welcome_activity);
final TextView countdownText = findViewById(R.id.countdownText);
new CountDownTimer(5000, 1000) {
@Override
public void onTick(long millisUntilFinished) {
int secondsRemaining = toIntExact(millisUntilFinished / 1000);
countdownText.setText(getResources().getQuantityString
(R.plurals.welcome_page_countdown, secondsRemaining, secondsRemaining));
}
@Override
public void onFinish() {
if (!WelcomeActivity.this.isFinishing()) {
finish();
}
}
}.start();
}
项目:sealtalk-android-master
文件:DownTimer.java
/**
* [倒计为time长的时间,时间间隔为mills]
* @param time
* @param mills
*/
public void startDown(long time, long mills) {
mCountDownTimer = new CountDownTimer(time, mills) {
@Override
public void onTick(long millisUntilFinished) {
if (listener != null) {
listener.onTick(millisUntilFinished);
} else {
NLog.e(TAG, "DownTimerListener 监听不能为空");
}
}
@Override
public void onFinish() {
if (listener != null) {
listener.onFinish();
} else {
NLog.e(TAG, "DownTimerListener 监听不能为空");
}
if (mCountDownTimer != null)mCountDownTimer.cancel();
}
} .start();
}
项目:Coin-Tracker
文件:SplashActivity.java
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();
}
项目:StyleableToast
文件:ToastLengthTracker.java
/**
* 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();
}
项目:GCSApp
文件:TributePayDelegate.java
public void setTime(long endTime) {
if (endTime != 0) {
tv_time_tip.setVisibility(View.VISIBLE);
timer = new CountDownTimer(endTime - System.currentTimeMillis(), 1000) {
@Override
public void onTick(long l) {
String tip = TimeUtil.getTimesEnd(l);
tv_time_tip.setText(tip);
}
@Override
public void onFinish() {
}
}.start();
} else {
tv_time_tip.setVisibility(View.GONE);
}
}
项目:accelerator-sample-apps-android
文件:MainActivity.java
private void showAll() {
mCallToolbar.setVisibility(View.GONE);
showAnnotationsToolbar(true);
mCountDownTimer = new CountDownTimer(3000, 1000) {
@Override
public void onTick(long millisUntilFinished) {
}
@Override
public void onFinish() {
if (isAnnotations) {
mCallToolbar.setVisibility(View.VISIBLE);
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mAnnotationsToolbar.getLayoutParams();
params.addRule(RelativeLayout.ABOVE, mCallToolbar.getId());
mAnnotationsToolbar.setLayoutParams(params);
mAnnotationsToolbar.setVisibility(View.VISIBLE);
mActionBarContainer.setVisibility(View.GONE);
}
}
}.start();
}
项目:rongyunDemo
文件:DownTimer.java
/**
* [倒计为time长的时间,时间间隔为mills]
* @param time
* @param mills
*/
public void startDown(long time, long mills) {
mCountDownTimer = new CountDownTimer(time, mills) {
@Override
public void onTick(long millisUntilFinished) {
if (listener != null) {
listener.onTick(millisUntilFinished);
} else {
NLog.e(TAG, "DownTimerListener 监听不能为空");
}
}
@Override
public void onFinish() {
if (listener != null) {
listener.onFinish();
} else {
NLog.e(TAG, "DownTimerListener 监听不能为空");
}
if (mCountDownTimer != null)mCountDownTimer.cancel();
}
} .start();
}
项目:BlogBookApp
文件:SwipePlaceHolderView.java
/**
* @param resolver
* @param isSwipeIn
*/
public void doSwipe(Object resolver, boolean isSwipeIn) {
if (mIsBtnSwipeDone) {
mIsBtnSwipeDone = false;
SwipeViewBinder swipeViewBinder = null;
for (SwipeViewBinder viewBinder : mSwipeViewBinderList) {
if (viewBinder.getResolver() == resolver) {
swipeViewBinder = viewBinder;
break;
}
}
if (swipeViewBinder != null) {
swipeViewBinder.doSwipe(isSwipeIn);
}
new CountDownTimer((int) (2.25 * mSwipeDecor.getSwipeAnimTime()), mSwipeDecor.getSwipeAnimTime()) {
public void onTick(long millisUntilFinished) {
}
public void onFinish() {
mIsBtnSwipeDone = true;
}
}.start();
}
}
项目:BlogBookApp
文件:SwipePlaceHolderView.java
/**
* @param isSwipeIn
*/
public void doSwipe(boolean isSwipeIn) {
if (mIsBtnSwipeDone) {
mIsBtnSwipeDone = false;
if (mSwipeViewBinderList.size() > 0) {
mSwipeViewBinderList.get(0).doSwipe(isSwipeIn);
}
new CountDownTimer((int) (2.25 * mSwipeDecor.getSwipeAnimTime()), mSwipeDecor.getSwipeAnimTime()) {
public void onTick(long millisUntilFinished) {
}
public void onFinish() {
mIsBtnSwipeDone = true;
}
}.start();
}
}
项目:QuizApp-Android
文件:FragStartGame.java
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.layout_start_game, container, false);
Log.e("FragmentStartGame","onCreateView");
startFragText = (TextView) view.findViewById(R.id.startFragmentText);
new CountDownTimer(5000, 100) {
public void onTick(long millisUntilFinished) {
startFragText.setText("Jocul începe în \n " + millisUntilFinished / 1000 + " ");
}
public void onFinish() {
closeFragment();
}
}.start();
view.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
return view;
}
项目:CCAvenue-Android-Example-Advanced
文件:OtpFragment.java
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.otp_fragment, container, false);
/*okBtn = (Button) view.findViewById(R.id.okBtn);
okBtn.setOnClickListener(this);*/
timerText = (TextView) view.findViewById(R.id.timerText);
new CountDownTimer(30000, 1000) {
public void onTick(long millisUntilFinished) {
timerText.setText("Time remaining: " + millisUntilFinished / 1000);
}
public void onFinish() {
//timerText.setText("done!");
}
}.start();
return view;
}
项目:PosTrainer
文件:AlarmService.java
private void playAlarmSound() throws java.io.IOException {
new CountDownTimer(30000, 1000) {
public void onTick(long millisUntilFinished) {
}
public void onFinish() {
if (mediaPlayer != null) {
mediaPlayer.stop();
mediaPlayer.release();
}
}
};
mediaPlayer.start();
}