11 package com.freerdp.freerdpcore.application;
13 import android.content.BroadcastReceiver;
14 import android.content.Context;
15 import android.content.Intent;
16 import android.net.ConnectivityManager;
17 import android.net.NetworkInfo;
18 import android.util.Log;
23 public static boolean isConnectedTo3G(Context context)
25 ConnectivityManager connectivity =
26 (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
27 NetworkInfo info = connectivity.getActiveNetworkInfo();
30 if (info ==
null || !info.isConnected())
33 return (info.getType() != ConnectivityManager.TYPE_WIFI &&
34 info.getType() != ConnectivityManager.TYPE_WIMAX);
37 @Override
public void onReceive(Context context, Intent intent)
41 if (intent.getExtras() !=
null)
44 (NetworkInfo)intent.getExtras().get(ConnectivityManager.EXTRA_NETWORK_INFO);
47 if (info !=
null && info.isConnected())
50 Log.d(
"app",
"Connected via type " + info.getTypeName());
51 GlobalApp.ConnectedTo3G = (info.getType() != ConnectivityManager.TYPE_WIFI &&
52 info.getType() != ConnectivityManager.TYPE_WIMAX);
55 Log.v(
"NetworkState", info.toString());