-2

How can I let my Android application code schedule an event to an API so that the event happens even if the Android phone is offline? I want the app to be free of charge and don't want to integrate cloud.

I didn't try anything.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Jokhyt
  • 11
  • The event will happen, yes, like here https://stackoverflow.com/questions/14376470/scheduling-recurring-task-in-android, but if it is offline it won't get any response. Probably you should rephrase and detail your question. – PeterMmm Aug 05 '23 at 18:13

1 Answers1

1

You don't, unless the API itself has a schedule functionality. If the device is offline, you can't send an HTTP request. Now if you want to schedule it for later and either don't care when it happens (just have it happen the next time you do have internet access), you can use JobScheduler to schedule a job in the future that will make the API call. Or if you want to do it at a specific time, you can use JobScheduler for that as well and just hope the device is online then (with an optional try again later if it isn't).

Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127
  • Thank you for the answer! My question for this is does AVS API have scheduling features? – Jokhyt Aug 05 '23 at 18:56
  • I have no idea what AVS API is. I would say that it would be extremely rare for an API to have one. Generally they only would if doing something in the future is a feature they provide- for example an API for an email service may let you schedule sending an email. But it will be a small minority that have something like that. – Gabe Sechan Aug 06 '23 at 02:27