I'm packaging a Flatpak application that checks the network availability on startup. Since switching to Flatpak packaging I've noticed that the GLib.NetworkMonitor is initially reporting no network availability, but very shortly thereafter the network-changed
signal is emitted to indicate that there is a network connection.
This appears to be Flatpak related - maybe due to the sandbox not having a connection initially?
I don't see this behavior documented anywhere, so I don't want to assume that there will always be a signal emitted initially.
public class MyApplication : Gtk.Application {
private bool is_network_available;
construct {
// After the application is fully started, UI initialized, etc. this gets
// triggered and reports change to `true`
network_monitor.network_changed.connect (() => {
debug ("Network availability changed: %s", network_monitor.get_network_available ().to_string ());
});
}
protected override void activate () {
// Check the initial state of the network connection
is_network_available = network_monitor.get_network_available ();
debug (is_network_available); // Reports false
}
}
Is this expected for Flatpak packaged applications? Is there a more reliable method to perform this check on startup?