NetworkInfo getSubtypeName - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for NetworkInfo getSubtypeName method.

This code example shows how to use the following methods:getSubtypeName
		return _info.getType();
	} 
	 
	@JSFunction("getSubtypeName") 
	public String getSubtypeName() {
		return _info.getSubtypeName();
	} 
	 
	@JSFunction("getSubtype") 
	public int getSubtype() { 
		return _info.getSubtype();
	} 
	 
	@JSFunction("getState") 
	public String getState() {
		return _info.getState().toString();
	} 
	 
	@JSFunction("getDetailedState") 
	public String getDetailedState() {
7
CodeRank
This code example shows how to use the following methods:getState, getSubtypeName, getTypeName
			} 
		 
			String status = "";
			 
			NetworkInfo currentNetInfo = conMgr.getActiveNetworkInfo();
			if((currentNetInfo != null) && (currentNetInfo.getState() == NetworkInfo.State.CONNECTED)) {
				String type = currentNetInfo.getTypeName();
				String subType = currentNetInfo.getSubtypeName();
				System.out.println("Network type: "+type+" "+subType);
				if(type.equals("WIFI")) { //find out if we have wifi
					status = "wifi";
				} 
				else if(type.equals("MOBILE")){ // or 3G
					status = "3G";
					/* check subType in the future to determine if we really have 3G, or just some other data (EDGE,  
				     * Roaming, etc.) 
				     * We'll also want to check for background data usage on Android  
				     */ 
				} 
				else{ 
6
CodeRank
This code example shows how to use the following methods:getSubtypeName, getTypeName, isConnected
     
    receiver = new BroadcastReceiver() {
      public void onReceive(Context context, Intent intent) {
        if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
          NetworkInfo info = intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
          String typeName = info.getTypeName();
          String subType = info.getSubtypeName();
          isConnected = info.isConnected();
          if (view != null) {
            try { 
              Method setNetworkType = view.getClass().getMethod("setNetworkType",
                  String.class, String.class);
              setNetworkType.invoke(view, typeName, (subType == null? "" : subType));
               
              boolean noConnection = intent.getBooleanExtra(
                  ConnectivityManager.EXTRA_NO_CONNECTIVITY, false);
              onNetworkChange(!noConnection);
            } catch (Exception e) {
              throw new RuntimeException(e);
            } 
6
CodeRank
This code example shows how to use the following methods:getSubtypeName, getTypeName, isConnectedOrConnecting, isRoaming
This code example shows how to use the following methods:getExtraInfo, getSubtypeName, getTypeName
    private static String getDataConnectionStatus() {
        String res = null;
         
        NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
         
        res = "Type: '" + networkInfo.getTypeName() 
            + "' SubType: '" + networkInfo.getSubtypeName()
            + "' ExtraInfo: '" + networkInfo.getExtraInfo()
            + "'"; 
         
        return res;
    } 
     
    private static void appendXMPPConnectionData(XmppMsg msg) {
        int reused = XmppManager.getReusedConnectionCount();
        int newcons = XmppManager.getNewConnectionCount();
        int total = reused + newcons;
        msg.appendBoldLine("XMPP Connection Data");
        msg.appendLine("Total connections: " + total + " thereof " + reused + " reused and " + newcons + " new");
    } 
6
CodeRank
This code example shows how to use the following methods:getSubtypeName, getTypeName, isConnected
     */ 
    private String getConnectionInfo(NetworkInfo info) {
        String type = TYPE_NONE;
        if (null != info) {
            // 如果没有连接到任何网络,则设置type为none 
            if (!info.isConnected()) {
                type = TYPE_NONE;
            } 
            else { 
                type = getType(info);
            } 
        } 
        return type;
    } 
 
    /** 
     * 生成一个新的 plugin result,并将其传回JS. 
     * 
     * @param type  网络连接类型,设置到xFace.network.connection.type 
     */ 

5
CodeRank
This code example shows how to use the following methods:getExtraInfo, getReason, getState, getSubtype, getSubtypeName
			ConnectivityManager __cm = (ConnectivityManager) _context.getActivity().getSystemService(Context.CONNECTIVITY_SERVICE);
			NetworkInfo __activityNet = __cm.getActiveNetworkInfo();
//			NetworkInfo __mobileNet = __cm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); 
//			NetworkInfo __wifiNet = __cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI); 
			FREObject __obj = FREObject.newObject("Object", null);
			__obj.setProperty("state", FREObject.newObject(__activityNet.getState().toString()));
			__obj.setProperty("type", FREObject.newObject(__activityNet.getType()));
			__obj.setProperty("typeName", FREObject.newObject(__activityNet.getTypeName()));
			__obj.setProperty("extraInfo", FREObject.newObject(__activityNet.getExtraInfo()));
			__obj.setProperty("reason", FREObject.newObject(__activityNet.getReason()));
			__obj.setProperty("subType", FREObject.newObject(__activityNet.getSubtype()));
			__obj.setProperty("subTypeName", FREObject.newObject(__activityNet.getSubtypeName()));
			__obj.setProperty("isAvailable", FREObject.newObject(__activityNet.isAvailable()));
			__obj.setProperty("isConnected", FREObject.newObject(__activityNet.isConnected()));
			__obj.setProperty("isConnectedOrConnecting", FREObject.newObject(__activityNet.isConnectedOrConnecting()));
			return __obj;
		} 
		catch(Exception $e)
		{ 
			_context.dispatchStatusEventAsync($e.getMessage(), TAG);
6
CodeRank
This code example shows how to use the following methods:getSubtypeName, getTypeName, isConnectedOrConnecting, isRoaming
This code example shows how to use the following methods:getSubtypeName, getTypeName, isConnected
     */ 
    private String getConnectionInfo(NetworkInfo info) {
        String type = TYPE_NONE;
        if (info != null) {
            // If we are not connected to any network set type to none 
            if (!info.isConnected()) {
                type = TYPE_NONE;
            } 
            else { 
                type = getType(info);
            } 
        } 
        return type;
    } 
 
    /** 
     * Create a new plugin result and send it back to JavaScript 
     * 
     * @param connection the network info to set as navigator.connection 
     */ 

5
CodeRank
This code example shows how to use the following methods:getSubtypeName, getTypeName, isAvailable
	{ 
		Log.i(LOGTAG, "Action: " + intent.getAction());
    	if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) 
    	{ 
		    NetworkInfo info = intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
		    String typeName = info.getTypeName();
		    String subtypeName = info.getSubtypeName();
		    boolean available = info.isAvailable();
		    Log.i(LOGTAG, "Network Type: " + typeName + ", subtype: " + subtypeName+ ", available: " + available);
		     
		    app = (AseMapApplication) ctx.getApplicationContext();
	 
		    if(!available)
		    { 
	            app.setNetworkStatus(false);
		    	Intent i = new Intent(ctx, ConnectivityIssue.class);
		    	i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		    	ctx.startActivity(i);
		    } 
		    else  
5
CodeRank

Related NetworkInfo getSubtypeName Questions & Answers:

getSubtypeName Method Overview
Return a human-readable name describing the subtype of the network.
See Code Examples for other Android NetworkInfo Methods: