FreeRDP
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Modules Pages
com.freerdp.freerdpcore.application.NetworkStateReceiver Class Reference
Inheritance diagram for com.freerdp.freerdpcore.application.NetworkStateReceiver:
Collaboration diagram for com.freerdp.freerdpcore.application.NetworkStateReceiver:

Public Member Functions

void onReceive (@NonNull Context context, @NonNull Intent intent)
 

Static Public Member Functions

static boolean isConnectedTo3G (Context context)
 

Detailed Description

Definition at line 22 of file NetworkStateReceiver.java.

Member Function Documentation

◆ isConnectedTo3G()

static boolean com.freerdp.freerdpcore.application.NetworkStateReceiver.isConnectedTo3G ( Context  context)
inlinestatic

Definition at line 25 of file NetworkStateReceiver.java.

26 {
27 ConnectivityManager connectivity =
28 (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
29 NetworkInfo info = connectivity.getActiveNetworkInfo();
30
31 // no connection or background data disabled
32 if (info == null || !info.isConnected())
33 return false;
34
35 return (info.getType() != ConnectivityManager.TYPE_WIFI &&
36 info.getType() != ConnectivityManager.TYPE_WIMAX);
37 }

◆ onReceive()

void com.freerdp.freerdpcore.application.NetworkStateReceiver.onReceive ( @NonNull Context  context,
@NonNull Intent  intent 
)
inline

Definition at line 39 of file NetworkStateReceiver.java.

40 {
41 String action = intent.getAction();
42 if (!action.equals("android.net.conn.CONNECTIVITY_CHANGE"))
43 {
44 return;
45 }
46
47 // check if we are connected via 3g or wlan
48 if (intent.getExtras() != null)
49 {
50 NetworkInfo info =
51 (NetworkInfo)intent.getExtras().get(ConnectivityManager.EXTRA_NETWORK_INFO);
52
53 // are we connected at all?
54 if (info != null)
55 {
56 if (info.isConnected())
57 {
58 // see if we are connected through 3G or WiFi
59 Log.d("app", "Connected via type " + info.getTypeName());
60 GlobalApp.ConnectedTo3G = (info.getType() != ConnectivityManager.TYPE_WIFI &&
61 info.getType() != ConnectivityManager.TYPE_WIMAX);
62 }
63
64 Log.v("NetworkState", info.toString());
65 }
66 }
67 }

The documentation for this class was generated from the following file: