use of java.util.Timer in project android_frameworks_base by ParanoidAndroid.
the class ComprehensiveCountryDetector method scheduleLocationRefresh.
/**
* Schedule the next location refresh. We will do nothing if the scheduled task exists.
*/
private synchronized void scheduleLocationRefresh() {
if (mLocationRefreshTimer != null)
return;
if (DEBUG) {
Slog.d(TAG, "start periodic location refresh timer. Interval: " + LOCATION_REFRESH_INTERVAL);
}
mLocationRefreshTimer = new Timer();
mLocationRefreshTimer.schedule(new TimerTask() {
@Override
public void run() {
if (DEBUG) {
Slog.d(TAG, "periodic location refresh event. Starts detecting Country code");
}
mLocationRefreshTimer = null;
detectCountry(false, true);
}
}, LOCATION_REFRESH_INTERVAL);
}
use of java.util.Timer in project android_frameworks_base by ParanoidAndroid.
the class LocationBasedCountryDetectorTest method waitForTimerReset.
private void waitForTimerReset(TestCountryDetector detector) {
int count = 5;
long interval = 1000;
try {
while (count-- > 0 && detector.getTimer() != null) {
Thread.sleep(interval);
}
} catch (InterruptedException e) {
}
Timer timer = detector.getTimer();
assertTrue(timer == null);
}
use of java.util.Timer in project simperium-android by Simperium.
the class WebSocketManager method scheduleHeartbeat.
private void scheduleHeartbeat() {
cancelHeartbeat();
mHeartbeatTimer = new Timer();
mHeartbeatTimer.schedule(new TimerTask() {
public void run() {
sendHearbeat();
}
}, HEARTBEAT_INTERVAL);
}
use of java.util.Timer in project storymaker by StoryMaker.
the class ProjectsProvider method setTimer.
synchronized void setTimer(long delay) {
// if there is no pin set, do not set a timer (will force a lock and potentially cause a crash)
SharedPreferences settings = getContext().getApplicationContext().getSharedPreferences("appPrefs", Context.MODE_PRIVATE);
String cachewordStatus = settings.getString("cacheword_status", null);
if (cachewordStatus == null) {
return;
}
// if there is an existing timer, clear it
if (dbTimer != null) {
dbTimer.cancel();
dbTimer = null;
}
// set timer to disconnect from cacheword service so it can timeout
dbTimer = new Timer();
dbTimer.schedule(new TimerTask() {
public void run() {
mCacheWordHandler.disconnectFromService();
dbTimer.cancel();
dbTimer = null;
}
}, // 1 min delay
delay);
}
use of java.util.Timer in project GT by Tencent.
the class DefaultParaRunEngine method runFps.
private synchronized void runFps() {
if (Env.API >= 14) {
fps_gather = true;
if (!hasCheckSu) {
thread = new Thread(new CheckSuRunnable(), "CheckSu");
thread.setDaemon(true);
thread.start();
}
// 因为这个Timer是延时执行,所以基本能赶上su判断线程出结果
fpsTimer40 = new Timer();
fpsTimer40.schedule(new FpsTimerTask(), 0, GTIntervalSettingActivity.msecond_FPS);
}
}
Aggregations