The server stores the schedule of matches. I need the application to send a GET request to the server every time at a certain interval and take a fresh schedule, even if the application is not running (the user will be notified if his team plays), but the Internet is turned on. The server returns the schedule in json format. How to implement it?

    2 answers 2

    You need to act like this:

    1. Subscribe to the launch of the device . Catching this event is necessary BroadcastReceiver th, registered in the manifest and subscribed to the event android.permission.RECEIVE_BOOT_COMPLETED . You also need the appropriate permission in the manifest.
    2. At the time of launching the device, you need to use the AlarmManager to create your own periodically sent content , which will call the 2nd BroadcastReceiver every n-minute
    3. Actions from the second point should also be done when the application is started. Otherwise, your intents will not be registered in the system until you restart the device.
    4. In the second BroadcastReceiver , launched when sending out your own intents, you need to run an IntentService in which you make a request to the server and output, if necessary, a notification

      In my opinion, for such a case, you do not need to send a request at a certain time interval, but send a notification from the server via Firebase cloud message. This is quite simple to set up.