Is there a way to check if the device is connected to the internet?

You should check this: