Last active
February 26, 2023 18:01
-
-
Save andigu/9890132261cfbf7ee25efc690eff53de to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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