mirror of https://github.com/M66B/NetGuard.git
Indicate no active network
This commit is contained in:
parent
fe70de0a0e
commit
2753db41c4
|
@ -610,6 +610,9 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
|
|||
|
||||
if (adapter != null)
|
||||
if (intent.hasExtra(EXTRA_CONNECTED) && intent.hasExtra(EXTRA_METERED)) {
|
||||
ivIcon.setImageResource(Util.isNetworkActive(ActivityMain.this)
|
||||
? R.drawable.ic_security_white_24dp
|
||||
: R.drawable.ic_security_white_24dp_60);
|
||||
if (intent.getBooleanExtra(EXTRA_CONNECTED, false)) {
|
||||
if (intent.getBooleanExtra(EXTRA_METERED, false))
|
||||
adapter.setMobileActive();
|
||||
|
|
|
@ -114,6 +114,11 @@ public class Util {
|
|||
}
|
||||
}
|
||||
|
||||
public static boolean isNetworkActive(Context context) {
|
||||
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
return (cm == null ? false : cm.getActiveNetworkInfo() != null);
|
||||
}
|
||||
|
||||
public static boolean isConnected(Context context) {
|
||||
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo ni = (cm == null ? null : cm.getActiveNetworkInfo());
|
||||
|
|
Loading…
Reference in New Issue