Android WorkRequest NetworkType constraint can't tell between VPN with internet and without

Viewed 265

I have a WorkRequest that I want to run when the device has an internet connection. Constraints seem to be the way to do this - I can define a NetworkType constraint like so:

val constraints = Constraints.Builder()
            .setRequiredNetworkType(NetworkType.CONNECTED)
            .build()

However, I have observed some behaviour for devices which use a VPN. When the VPN is active, it appears that the WorkRequest considers this as NetworkType.CONNECTED, even if the device does not have an internet connection.

Is there any way to make the constraint work as I expected?

Thanks in advance :)

1 Answers
Related