Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in Android ConnectivityManager property #310

Closed
2 of 13 tasks
markdou812 opened this issue May 20, 2016 · 2 comments
Closed
2 of 13 tasks

Bug in Android ConnectivityManager property #310

markdou812 opened this issue May 20, 2016 · 2 comments

Comments

@markdou812
Copy link
Contributor

Please take a moment to fill out the following (change to preview to check or place x in []):

This is a

  • Bug
  • Feature Request

Which plugin does this impact:

  • Battery
  • Connectivity
  • Contacts
  • DeviceInfo
  • ExternalMaps
  • Geolocator
  • Media
  • Permissions
  • Settings
  • Text To Speech
  • Vibrate
  • Other:

Version Number of Plugin: 2.1.2
Device Tested On: OnePlus One, LG G4
Simulator Tested On:

Expected Behavior

Connect to wifi network in your Android Wifi settings. Run app and exercise the IsConnected property. Change to a different wifi network and repeat. The IsConnected status should be correct.

Actual Behavior

Sometimes when you switch hosts in your wifi settings while running an app, your ConnectivityManager property in ConnectivityImplementation.cs will return an instance that has already been disposed (Handle == IntPtr.Zero). Then you get a false negative when you call IsConnected since it goes into the Exception handler.

Changing the ConnectivityManager property to this fixes the bug:
ConnectivityManager ConnectivityManager
{
get
{
if (_connectivityManager == null || _connectivityManager.Handle == IntPtr.Zero)
_connectivityManager = (ConnectivityManager)(Application.Context.GetSystemService(Context.ConnectivityService));

            return _connectivityManager;
        }
    }

Steps to reproduce the Behavior

@jamesmontemagno
Copy link
Owner

I recommend sending down a pull request so I can attempt to repo.

Thanks!

@jamesmontemagno
Copy link
Owner

Moved to: jamesmontemagno/ConnectivityPlugin#3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants