|
|
@ -5,13 +5,14 @@ import android.content.Context; |
|
|
|
import android.content.Intent; |
|
|
|
import android.content.Intent; |
|
|
|
import android.net.ConnectivityManager; |
|
|
|
import android.net.ConnectivityManager; |
|
|
|
import android.net.NetworkInfo; |
|
|
|
import android.net.NetworkInfo; |
|
|
|
|
|
|
|
import android.support.annotation.NonNull; |
|
|
|
|
|
|
|
|
|
|
|
public class NetworkReceiver extends BroadcastReceiver { |
|
|
|
public class NetworkReceiver extends BroadcastReceiver { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onReceive(Context context, Intent intent) {} |
|
|
|
public void onReceive(Context context, Intent intent) {} |
|
|
|
|
|
|
|
|
|
|
|
public static boolean isConnected(Context context) { |
|
|
|
public static boolean isConnected(@NonNull Context context) { |
|
|
|
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); |
|
|
|
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); |
|
|
|
if (cm == null) |
|
|
|
if (cm == null) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|