List of usage examples for android.net ConnectivityManager TYPE_WIFI
int TYPE_WIFI
To view the source code for android.net ConnectivityManager TYPE_WIFI.
Click Source Link
From source file:com.wojtechnology.sunami.TheBrain.java
public boolean isSoundcloudEnabled() { if (!mMainPrefs.isSoundcloudEnabled) return false; ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService( Service.CONNECTIVITY_SERVICE); NetworkInfo wifi = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); NetworkInfo connection = connectivityManager.getActiveNetworkInfo(); return wifi.isConnected() || (!mMainPrefs.forceOverWifi && connection != null && connection.isConnected()); }
From source file:com.tapjoy.TapjoyConnectCore.java
/** * Gets the connection type used by this device ("mobile" or "wifi"). * @return Connection type the device is using. *///from w ww. j av a 2 s. c o m public static String getConnectionType() { String type = ""; // Adding this try/catch for weird nullPointerException issue which rarely occurs on certain hardware ? try { // Get connection type. ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); // Might be null on airplane mode. if (connectivityManager != null && connectivityManager.getActiveNetworkInfo() != null) { switch (connectivityManager.getActiveNetworkInfo().getType()) { case ConnectivityManager.TYPE_WIFI: case 0x6: //case ConnectivityManager.TYPE_WIMAX is 0x6 type = "wifi"; break; default: type = "mobile"; break; } TapjoyLog.i(TAPJOY_CONNECT, "connectivity: " + connectivityManager.getActiveNetworkInfo().getType()); TapjoyLog.i(TAPJOY_CONNECT, "connection_type: " + type); } } catch (Exception e) { TapjoyLog.e(TAPJOY_CONNECT, "getConnectionType error: " + e.toString()); } return type; }
From source file:com.halseyburgund.rwframework.core.RWService.java
/** * Checks if data connectivity is available, honoring the flag * mOnlyConnectOverWifi to accept only WiFi and not mobile data * connections./*www . ja v a2s. c o m*/ * * @return true if data connectivity is available */ public boolean isConnected() { ConnectivityManager cm = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE); NetworkInfo ni = cm.getActiveNetworkInfo(); if ((ni != null) && (ni.isConnected())) { if ((mOnlyConnectOverWiFi) && (!(ni.getType() == ConnectivityManager.TYPE_WIFI))) { return false; } return true; } return false; }
From source file:layout.FragmentBoardItemList.java
private void getThumbnail(final BoardItem bi) { bi.downloadingThumb = true;//from w ww . j av a 2 s. co m ConnectivityManager cm = (ConnectivityManager) getContext().getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = cm.getActiveNetworkInfo(); boolean usingWifi = (info != null && info.isConnected() && info.getType() == ConnectivityManager.TYPE_WIFI); ContextWrapper cw = new ContextWrapper(getActivity().getApplicationContext()); File directory = cw.getDir("thumbs", Context.MODE_PRIVATE); if (!directory.exists()) { directory.mkdir(); } final File mypath; if (bi.youtubeLink) { mypath = new File(directory, currentBoard.getBoardDir() + "_" + bi.youtubeID); } else { mypath = new File(directory, currentBoard.getBoardDir() + "_" + bi.getThumb()); } if (mypath.exists()) { try { Bitmap b = BitmapFactory.decodeStream(new FileInputStream(mypath)); bi.setThumbBitmap(Bitmap.createScaledBitmap(b, 128, 128, false)); listViewAdapter.notifyDataSetChanged(); Log.i("getThumb", bi.getThumb() + " from cache"); return; } catch (Exception e) { e.printStackTrace(); displayError(e.getMessage()); } } if (settings.getBoolean("setting_downloadOnlyWithWifi", false) == true && !usingWifi) { Log.i("getThumb", "Not using wifi"); return; } String imgURL = "http://bienvenidoainternet.org/" + bi.getParentBoard().getBoardDir() + "/thumb/" + bi.getThumb(); if (bi.getThumb().startsWith("http")) { imgURL = bi.getThumb(); } Ion.with(getContext()).load(imgURL).setLogging("getThumbnail", Log.INFO).asBitmap() .setCallback(new FutureCallback<Bitmap>() { @Override public void onCompleted(Exception e, Bitmap result) { if (e != null) { displayError(e.getMessage()); e.printStackTrace(); } else { bi.setThumbBitmap(Bitmap.createScaledBitmap(result, 128, 128, false)); listViewAdapter.notifyDataSetChanged(); FileOutputStream out; try { out = new FileOutputStream(mypath); result.compress(Bitmap.CompressFormat.PNG, 100, out); if (out != null) { out.close(); } Log.v("getThumb", bi.getThumb() + " saved."); } catch (Exception e1) { e1.printStackTrace(); } } } }); }
From source file:github.daneren2005.dsub.util.Util.java
public static boolean isNetworkConnected(Context context, boolean streaming) { ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = manager.getActiveNetworkInfo(); boolean connected = networkInfo != null && networkInfo.isConnected(); if (streaming) { boolean wifiConnected = connected && networkInfo.getType() == ConnectivityManager.TYPE_WIFI; boolean wifiRequired = isWifiRequiredForDownload(context); return connected && (!wifiRequired || wifiConnected); } else {/*from ww w.ja va 2s .c o m*/ return connected; } }
From source file:github.daneren2005.dsub.util.Util.java
public static boolean isWifiConnected(Context context) { ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = manager.getActiveNetworkInfo(); boolean connected = networkInfo != null && networkInfo.isConnected(); return connected && (networkInfo.getType() == ConnectivityManager.TYPE_WIFI); }
From source file:com.z3r0byte.magistify.Services.BackgroundService.java
private Boolean usingWifi() { final ConnectivityManager connMgr = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); if (connMgr == null) return false; NetworkInfo activeNetwork = connMgr.getActiveNetworkInfo(); return activeNetwork != null && activeNetwork.getType() == ConnectivityManager.TYPE_WIFI; }
From source file:org.opensilk.music.artwork.ArtworkRequestManagerImpl.java
boolean isOnline(boolean wifiOnly) { boolean state = false; /* Wi-Fi connection */ final NetworkInfo wifiNetwork = mConnectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); if (wifiNetwork != null) { state = wifiNetwork.isConnectedOrConnecting(); }/*ww w .ja v a 2s. c o m*/ // Don't bother checking the rest if we are connected or we have opted out of mobile if (wifiOnly || state) { return state; } /* Mobile data connection */ final NetworkInfo mbobileNetwork = mConnectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); if (mbobileNetwork != null) { state = mbobileNetwork.isConnectedOrConnecting(); } /* Other networks */ final NetworkInfo activeNetwork = mConnectivityManager.getActiveNetworkInfo(); if (activeNetwork != null) { state = activeNetwork.isConnectedOrConnecting(); } return state; }
From source file:cx.ring.service.LocalService.java
private void updateConnectivityState() { ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo ni = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI); Log.w(TAG, "ActiveNetworkInfo (Wifi): " + (ni == null ? "null" : ni.toString())); isWifiConn = ni != null && ni.isConnected(); ni = cm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); Log.w(TAG, "ActiveNetworkInfo (mobile): " + (ni == null ? "null" : ni.toString())); isMobileConn = ni != null && ni.isConnected(); try {/* w w w . jav a2 s . c om*/ getRemoteService().setAccountsActive(isConnected()); } catch (RemoteException e) { e.printStackTrace(); } // if account list loaded if (!ip2ip_account.isEmpty()) sendBroadcast(new Intent(ACTION_ACCOUNT_UPDATE)); }
From source file:com.thejoshwa.ultrasonic.androidapp.util.Util.java
public static int getMaxVideoBitrate(Context context) { ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = manager.getActiveNetworkInfo(); if (networkInfo == null) { return 0; }//from w ww .java2 s . c o m boolean wifi = networkInfo.getType() == ConnectivityManager.TYPE_WIFI; SharedPreferences prefs = getPreferences(context); return Integer.parseInt(prefs.getString(wifi ? Constants.PREFERENCES_KEY_MAX_VIDEO_BITRATE_WIFI : Constants.PREFERENCES_KEY_MAX_VIDEO_BITRATE_MOBILE, "0")); }