List of usage examples for android.net ConnectivityManager setNetworkPreference
@Deprecated public void setNetworkPreference(int preference)
From source file:com.moodmap.SplashScreenActivity.java
public boolean networkStatus(Activity context) { boolean status = false; int i = 0;/* w w w. j a v a2 s . c o m*/ try { String service = Context.CONNECTIVITY_SERVICE; ConnectivityManager connectivity = (ConnectivityManager) context.getSystemService(service); connectivity.setNetworkPreference(1); NetworkInfo networkInfo[] = connectivity.getAllNetworkInfo(); int cnt = networkInfo.length; for (i = 0; i < cnt; i++) { if (networkInfo[i].isConnected() == true) { status = true; Log.v("Network Provider", "" + networkInfo[i].getTypeName()); } } } catch (Exception ee) { ee.printStackTrace(); } Log.v("networkStatus", "##########" + status); return status; }
From source file:com.codename1.impl.android.AndroidImplementation.java
/** * @inheritDoc//from w w w . j ava 2 s .c o m */ public void setCurrentAccessPoint(String id) { if (apIds == null) { getAPIds(); } NetworkInfo info = (NetworkInfo) apIds.get(id); if (info == null || info.isConnectedOrConnecting()) { return; } ConnectivityManager cm = (ConnectivityManager) getContext().getSystemService(Context.CONNECTIVITY_SERVICE); cm.setNetworkPreference(info.getType()); }