38 lines
1.3 KiB
Java
38 lines
1.3 KiB
Java
package com.ubtrobot.analytics;
|
|
|
|
import android.content.BroadcastReceiver;
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.net.ConnectivityManager;
|
|
import android.net.NetworkInfo;
|
|
import android.util.Log;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public class NetWorkChangeReceiver extends BroadcastReceiver {
|
|
private INetWorkChange a;
|
|
|
|
public interface INetWorkChange {
|
|
void a();
|
|
}
|
|
|
|
public NetWorkChangeReceiver(INetWorkChange iNetWorkChange) {
|
|
this.a = iNetWorkChange;
|
|
}
|
|
|
|
@Override // android.content.BroadcastReceiver
|
|
public void onReceive(Context context, Intent intent) {
|
|
Log.i("Analytics", "Action: " + intent.getAction());
|
|
if ("android.net.conn.CONNECTIVITY_CHANGE".equals(intent.getAction())) {
|
|
NetworkInfo activeNetworkInfo = ((ConnectivityManager) context.getSystemService("connectivity")).getActiveNetworkInfo();
|
|
if (activeNetworkInfo == null) {
|
|
Log.w("Analytics", "NetworkInfo get fail.");
|
|
} else if (NetworkInfo.State.CONNECTED != activeNetworkInfo.getState() || !activeNetworkInfo.isConnected()) {
|
|
Log.w("Analytics", "NetWork is not connect.");
|
|
} else {
|
|
Log.i("Analytics", "NetWork is connected.");
|
|
this.a.a();
|
|
}
|
|
}
|
|
}
|
|
}
|