ConnectivityManager leaking, not sure how to resolve

Use this to prevent leak,

ConnectivityManager connectivityManager = (ConnectivityManager) context.getApplicationContext()
                .getSystemService(Context.CONNECTIVITY_SERVICE);

This is a bug on Android M and has been fixed on L.

The reason is that on M, ConnectivityManager holds the first instance as a static object.

When you get it first using an Activity Context, the static object will always have reference to your Activity. Using the Application Context will solve the problem.