Left: | ||
Right: |
OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | |
3 * Copyright (C) 2006-present eyeo GmbH | |
4 * | |
5 * Adblock Plus is free software: you can redistribute it and/or modify | |
6 * it under the terms of the GNU General Public License version 3 as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * Adblock Plus is distributed in the hope that it will be useful, | |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 * GNU General Public License for more details. | |
13 * | |
14 * You should have received a copy of the GNU General Public License | |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | |
16 */ | |
17 | |
18 package org.adblockplus.sbrowser.contentblocker.util; | |
19 | |
20 import android.content.Context; | |
21 import android.net.ConnectivityManager; | |
22 import android.net.NetworkInfo; | |
23 | |
24 public class ConnectivityUtils | |
25 { | |
26 public static boolean hasWifiConnection(final Context context) | |
27 { | |
28 final ConnectivityManager connManager = (ConnectivityManager) context | |
29 .getSystemService(Context.CONNECTIVITY_SERVICE); | |
30 final NetworkInfo current = connManager.getActiveNetworkInfo(); | |
31 return current != null && current.getType() == ConnectivityManager.TYPE_WIFI ; | |
diegocarloslima
2018/01/19 13:59:00
I think its interesting to also consider Bluetooth
jens
2018/01/19 14:32:55
Acknowledged.
| |
32 } | |
33 | |
34 public static boolean hasInternetConnection(final Context context) | |
35 { | |
36 final ConnectivityManager connManager = (ConnectivityManager) context | |
37 .getSystemService(Context.CONNECTIVITY_SERVICE); | |
38 return connManager != null && connManager.getActiveNetworkInfo() != null; | |
diegocarloslima
2018/01/19 13:59:00
Seems that connManager.getActiveNetworkInfo().isCo
jens
2018/01/19 14:32:55
Acknowledged.
| |
39 } | |
40 } | |
OLD | NEW |