-
-
Notifications
You must be signed in to change notification settings - Fork 73
ConnectivityChanged fired only once #143
Comments
It works (or rather doesn't work...) exactly the same way on latest Oreo 8.1.0 |
How are you testing it? Works perfect on about 10 of my different devices. |
I've faced a similar issue that might be related to the current one. In short:
I've investigated the code deeper and it appeared, that The reason why this happens is To workaround the issue in my app, I've decided to subscribe for async void ConnectivityTypeChanged (object sender, ConnectivityTypeChangedEventArgs args)
{
if (args.ConnectionTypes.Any() && !args.IsConnected)
{
var connected = await connectivity.AwaitConnected (TimeSpan.FromSeconds (10));
// do your stuff here
}
}
// And extension method
public static async Task<bool> AwaitConnected (this IConnectivity connectivity, TimeSpan timeout)
{
var end = DateTime.Now + timeout;
do
{
if (connectivity.IsConnected)
return true;
await Task.Delay (1000);
} while (DateTime.Now < end);
return false;
} This is not a perfect solution, as the case when internet connection appears after 20 seconds or more is real (for example device connected to the WiFi but there is no internet for some time). |
@jamesmontemagno I test it on Pixel 2 with VS for Mac debugger. I see a breakpoint hit in event handler when I turn-on airplane mode but when I turn it off (and in subsequent toggles) the handler doesn't execute. It works well on iOS. |
I've similar issue. For some reason when i turn on my WIFI it doesn't trigger ConnectivityChanged event. |
Anything on this? If I run the app and put it in airplane mode and do some stuff then take it out of airplane mode the event fires and my local data goes upstream. If I put it in airplane mode again and do some work and then take it back out of airplane mode it does not notify. I am setting up the handler in my .NET Standard Library 2.0 in App.xaml.cs like so CrossConnectivity.Current.ConnectivityChanged += Current_ConnectivityChanged; Am I missing something ? |
Have you tried: 3.1.1.185-beta Also if you want "all" changes then do connectivitytypechanged |
I'm also seeing this behavior. Steps to reproduce:
Environment:
Code:
Entire output, even after waiting several minutes:
3.1.1.185-beta appears to resolve the issue partially but toggling connectivity several times does see the same symptoms. |
Apologies, I just noticed this additional behavior: On Android on 3.1.1.185-beta, Environment:
|
@jamesmontemagno I am seeing the same issue - On Android (testing on a Samsung S8), ConnectivityChanged fires the first time, but then does not fire again. I am attempting to trigger it using airplane mode on my physical device. |
Try commenting out |
Can you try Xamarin.Essentials out and let me know if you see it there: https://docs.microsoft.com/en-us/xamarin/essentials/connectivity?context=xamarin%2Fandroid&tabs=ios This is a newer updated API and I will be re-working mine to use it soon. |
@jamesmontemagno Xamarin.Essentials Xam.Plugin.Connectivity (v4.0.0.186-beta, v3.1.1) I rebuilt Xam.Plugin.Connectivity v3.1.1 without the aforementioned Android wants you to only context-register broadcast receiver, statically registering it causes problems.
|
Please try latest 3.1.1.189-beta |
Confirmed: 3.1.1.189-beta API 24 - OK |
yay! |
ConnectivityChanged fired only once on android device version 7.0
Bug Information
Version Number of Plugin: 3.1.1
Device Tested android version 7.0
Version of VS: 2017 15.5.7
Steps to reproduce the Behavior
just create a simple xamarin.forms solution with android, then write a code below. all permissions were setted up in manifest.
Code snippet
##App.xaml.cs
##Page 1.xaml.cs
The text was updated successfully, but these errors were encountered: