0

I am developing an Android App for Android 5 (it's only for a specific device) and I need to monitor network connectivity. I would like to see it work this way:

  1. The application starts and checks whether there is a connection and what is its type.
  2. The Internet connection is checked every X seconds (e.g 3 seconds) or only changes are detected.

My question is: what is the best way to do it? JobScheduler, AlarmManager or it can be done only with BroadcastReceiver (with CONNECTIVITY_ACTION)?

I tried with JobScheduler with setPeriodic function, but it doesn't start immediately as I wanted. And I read that in higher version of Android the minimum period is 15 minutes. BroadcastReceiver with CONNECTIVITY_ACTION seems to break the connection after several minutes.

bogóś
  • 51
  • 7

2 Answers2

0

If the app is only meant to be used in Android 5 i.e. Lollipop you can use something like this. You can use a broadcast receiver as mentioned there.

0

You have to use Broadcast-Receiver. When the android device get internet connectivity it throws a broadcast to the device. Simply you have to receive that broadcast to the app.