Android开发中定时与延时的运用
2019-07-23 本文已影响0人
Cedric_h
原文:https://blog.csdn.net/uyy203/article/details/50771434
private void unceasingDiscovery(){
final Timer mTimer=new Timer();
TimerTask mTimerTask=new TimerTask() {
@Override
public void run() {
// TODO 自动生成的方法存根
if(mBluetoothAdapter.isDiscovering())
mBluetoothAdapter.cancelDiscovery();
else
mBluetoothAdapter.startDiscovery();
}
};
//开始一个定时任务,延时500ms,周期为800ms
mTimer.schedule(mTimerTask, 500,800);
}