Skip to content

Instantly share code, notes, and snippets.

@andigu
Last active February 26, 2023 18:01
Show Gist options
  • Save andigu/9890132261cfbf7ee25efc690eff53de to your computer and use it in GitHub Desktop.
Save andigu/9890132261cfbf7ee25efc690eff53de to your computer and use it in GitHub Desktop.
public class AlarmService extends HeadlessJsTaskService {
static long lastActive = 0;
@Override
protected @Nullable
HeadlessJsTaskConfig getTaskConfig(Intent intent) {
long current = System.currentTimeMillis();
if ((current - lastActive) >= 30 * 1000) {
lastActive = current;
return new HeadlessJsTaskConfig(
"checkAlarms",
null,
10000, true);
}
else return null;
}
public void onCreate() {
super.onCreate();
}
@Override
public IBinder onBind(Intent intent) {
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment