Java Code Examples for android.net.ConnectivityManager#TYPE_DUMMY
The following examples show how to use
android.net.ConnectivityManager#TYPE_DUMMY .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NotificationService.java From Aria2App with GNU General Public License v3.0 | 6 votes |
private void recreateWebsockets(int networkType) { clearWebsockets(); for (MultiProfile multi : new ArrayList<>(profiles)) { MultiProfile.UserProfile profile; if (networkType == ConnectivityManager.TYPE_DUMMY) profile = multi.getProfile(this); else profile = multi.getProfile(networkType, wifiManager); if (profile.connectionMethod == MultiProfile.ConnectionMethod.HTTP) { notifyUnsupportedConnectionMethod(profile); continue; } synchronized (webSockets) { try { webSockets.add(NetUtils.buildClient(profile).newWebSocket(NetUtils.createWebsocketRequest(profile), new NotificationsHandler(profile))); } catch (IOException | NetUtils.InvalidUrlException | GeneralSecurityException ex) { notifyException(profile, ex); } } } updateForegroundNotification(); }
Example 2
Source File: NotificationService.java From Aria2App with GNU General Public License v3.0 | 6 votes |
@Override public void onReceive(Context context, Intent intent) { if (profiles != null && wifiManager != null && Objects.equals(intent.getAction(), ConnectivityManager.CONNECTIVITY_ACTION)) { boolean noConnectivity = intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, false); if (!noConnectivity) { int networkType = intent.getIntExtra(ConnectivityManager.EXTRA_NETWORK_TYPE, ConnectivityManager.TYPE_DUMMY); if (networkType == ConnectivityManager.TYPE_DUMMY) return; if (messenger != null) { try { messenger.send(Message.obtain(null, MESSENGER_RECREATE_WEBSOCKETS, networkType, 0)); return; } catch (RemoteException ignored) { } } recreateWebsockets(networkType); } } }
Example 3
Source File: AppNetworkMgr.java From AndroidWallet with GNU General Public License v3.0 | 5 votes |
/** * 判断当前网络的类型是否是虚拟网络 * * @param context 上下文 * @return 当前网络的类型是否是虚拟网络。false:当前没有网络连接或者网络类型不是虚拟网络 */ @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) public static boolean isDummyByType(Context context) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR2) { return false; } else { return getCurrentNetworkType(context) == ConnectivityManager.TYPE_DUMMY; } }
Example 4
Source File: Util.java From android-notification-log with MIT License | 5 votes |
public static String getConnectivityType(Context context) { try { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); if(cm != null) { NetworkInfo networkInfo = cm.getActiveNetworkInfo(); if(networkInfo != null) { int type = networkInfo.getType(); switch (type) { case ConnectivityManager.TYPE_BLUETOOTH: return "bluetooth"; case ConnectivityManager.TYPE_DUMMY: return "dummy"; case ConnectivityManager.TYPE_ETHERNET: return "ethernet"; case ConnectivityManager.TYPE_MOBILE: return "mobile"; case ConnectivityManager.TYPE_MOBILE_DUN: return "mobile dun"; case ConnectivityManager.TYPE_VPN: return "vpn"; case ConnectivityManager.TYPE_WIFI: return "wifi"; case ConnectivityManager.TYPE_WIMAX: return "wimax"; default: return ""+type; } } else { return "none"; } } } catch (Exception e) { if(Const.DEBUG) e.printStackTrace(); } return "undefined"; }
Example 5
Source File: NetWorkUtils.java From Simpler with Apache License 2.0 | 5 votes |
/** * 判断当前网络的类型是否是虚拟网络 * * @param context 上下文 * @return 当前网络的类型是否是虚拟网络。false:当前没有网络连接或者网络类型不是虚拟网络 */ @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) public static boolean isDummyByType(Context context) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR2) { return false; } else { return getCurrentNetworkType(context) == ConnectivityManager.TYPE_DUMMY; } }
Example 6
Source File: NetWorkUtils.java From GankGirl with GNU Lesser General Public License v2.1 | 5 votes |
/** * 判断当前网络的类型是否是虚拟网络 * * @param context 上下文 * @return 当前网络的类型是否是虚拟网络。false:当前没有网络连接或者网络类型不是虚拟网络 */ @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) public static boolean isDummyByType(Context context) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR2) { return false; } else { return getCurrentNetworkType(context) == ConnectivityManager.TYPE_DUMMY; } }
Example 7
Source File: NetworkUtil.java From RxZhihuDaily with MIT License | 5 votes |
private static String getNetworkTypeName(int type) { switch (type) { case ConnectivityManager.TYPE_MOBILE: return "MOBILE"; case ConnectivityManager.TYPE_WIFI: return "WIFI"; case ConnectivityManager.TYPE_MOBILE_MMS: return "MOBILE_MMS"; case ConnectivityManager.TYPE_MOBILE_SUPL: return "MOBILE_SUPL"; case ConnectivityManager.TYPE_MOBILE_DUN: return "MOBILE_DUN"; case ConnectivityManager.TYPE_MOBILE_HIPRI: return "MOBILE_HIPRI"; case ConnectivityManager.TYPE_WIMAX: return "WIMAX"; case ConnectivityManager.TYPE_BLUETOOTH: return "BLUETOOTH"; case ConnectivityManager.TYPE_DUMMY: return "DUMMY"; case ConnectivityManager.TYPE_ETHERNET: return "ETHERNET"; case 10: // ConnectivityManager.TYPE_MOBILE_FOTA: return "MOBILE_FOTA"; case 11: // ConnectivityManager.TYPE_MOBILE_IMS: return "MOBILE_IMS"; case 12: // ConnectivityManager.TYPE_MOBILE_CBS: return "MOBILE_CBS"; case 13: // ConnectivityManager.TYPE_WIFI_P2P: return "WIFI_P2P"; default: return Integer.toString(type); } }
Example 8
Source File: NetworkUtil.java From NIM_Android_UIKit with MIT License | 5 votes |
private static String getNetworkTypeName(int type) { switch (type) { case ConnectivityManager.TYPE_MOBILE: return "MOBILE"; case ConnectivityManager.TYPE_WIFI: return "WIFI"; case ConnectivityManager.TYPE_MOBILE_MMS: return "MOBILE_MMS"; case ConnectivityManager.TYPE_MOBILE_SUPL: return "MOBILE_SUPL"; case ConnectivityManager.TYPE_MOBILE_DUN: return "MOBILE_DUN"; case ConnectivityManager.TYPE_MOBILE_HIPRI: return "MOBILE_HIPRI"; case ConnectivityManager.TYPE_WIMAX: return "WIMAX"; case ConnectivityManager.TYPE_BLUETOOTH: return "BLUETOOTH"; case ConnectivityManager.TYPE_DUMMY: return "DUMMY"; case ConnectivityManager.TYPE_ETHERNET: return "ETHERNET"; case 10: // ConnectivityManager.TYPE_MOBILE_FOTA: return "MOBILE_FOTA"; case 11: // ConnectivityManager.TYPE_MOBILE_IMS: return "MOBILE_IMS"; case 12: // ConnectivityManager.TYPE_MOBILE_CBS: return "MOBILE_CBS"; case 13: // ConnectivityManager.TYPE_WIFI_P2P: return "WIFI_P2P"; default: return Integer.toString(type); } }
Example 9
Source File: SPV.java From green_android with GNU General Public License v3.0 | 4 votes |
public SPV() { mNetWorkType = ConnectivityManager.TYPE_DUMMY; }
Example 10
Source File: SPV.java From green_android with GNU General Public License v3.0 | 4 votes |
private int getNetworkType(final NetworkInfo info) { if (info == null) return ConnectivityManager.TYPE_DUMMY; final int type = info.getType(); return type == ConnectivityManager.TYPE_MOBILE ? type : ConnectivityManager.TYPE_ETHERNET; }
Example 11
Source File: SPV.java From green_android with GNU General Public License v3.0 | 4 votes |
private void reset(final boolean deleteAllData, final boolean deleteUnspent) { synchronized (mStateLock) { Log.d(TAG, "reset: " + Var("deleteAllData", deleteAllData) + Var("deleteUnspent", deleteUnspent)); stopSync(); if (deleteAllData) { Log.d(TAG, "Deleting chain file"); mService.getSPVChainFile().delete(); try { Log.d(TAG, "Clearing verified and spendable transactions"); // TODO not a namespace anymore, delete all preferences starting with? //mService.cfgInEdit(SPENDABLE).clear().commit(); //mService.cfgInEdit(VERIFIED).clear().commit(); } catch (final NullPointerException e) { // ignore } } if (deleteUnspent) { Log.d(TAG, "Resetting unspent outputs"); mUnspentDetails.clear(); mUnspentOutpoints.clear(); mCountedUtxoValues.clear(); mVerifiedCoinBalances.clear(); } if (isEnabled()) { setup(); // We might race with our network callbacks, so fetch the network type // if its unknown. if (mNetWorkType == ConnectivityManager.TYPE_DUMMY) mNetWorkType = getNetworkType(); if (isSyncOnMobileEnabled() || mNetWorkType != ConnectivityManager.TYPE_MOBILE) startSync(); } Log.d(TAG, "Finished reset"); } }
Example 12
Source File: SPV.java From GreenBits with GNU General Public License v3.0 | 4 votes |
public SPV(final GaService service) { mService = service; mNetWorkType = ConnectivityManager.TYPE_DUMMY; }
Example 13
Source File: SPV.java From GreenBits with GNU General Public License v3.0 | 4 votes |
private int getNetworkType(final NetworkInfo info) { if (info == null) return ConnectivityManager.TYPE_DUMMY; final int type = info.getType(); return type == ConnectivityManager.TYPE_MOBILE ? type : ConnectivityManager.TYPE_ETHERNET; }
Example 14
Source File: SPV.java From GreenBits with GNU General Public License v3.0 | 4 votes |
private void reset(final boolean deleteAllData, final boolean deleteUnspent) { synchronized (mStateLock) { Log.d(TAG, "reset: " + Var("deleteAllData", deleteAllData) + Var("deleteUnspent", deleteUnspent)); stopSync(); if (deleteAllData) { Log.d(TAG, "Deleting chain file"); mService.getSPVChainFile().delete(); try { Log.d(TAG, "Clearing verified and spendable transactions"); mService.cfgInEdit(SPENDABLE).clear().commit(); mService.cfgInEdit(VERIFIED).clear().commit(); } catch (final NullPointerException e) { // ignore } } if (deleteUnspent) { Log.d(TAG, "Resetting unspent outputs"); mUnspentDetails.clear(); mUnspentOutpoints.clear(); mCountedUtxoValues.clear(); mVerifiedCoinBalances.clear(); } if (isEnabled()) { setup(); // We might race with our network callbacks, so fetch the network type // if its unknown. if (mNetWorkType == ConnectivityManager.TYPE_DUMMY) mNetWorkType = getNetworkType(); if (isSyncOnMobileEnabled() || mNetWorkType != ConnectivityManager.TYPE_MOBILE) startSync(); } Log.d(TAG, "Finished reset"); } }
Example 15
Source File: AppConstants.java From barterli_android with Apache License 2.0 | 4 votes |
public void reset() { mIsNetworkConnected = false; mCurrentNetworkType = ConnectivityManager.TYPE_DUMMY; mLatestLocation = defaultLocation; }