TelephonyManager getDataState - top ranked examples from Open Source projects

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

This code example shows how to use the following methods:getDataState
	} 
 
	private boolean checkConnectivityState(){ 
		final TelephonyManager telephonyManager = (TelephonyManager) mContext
				.getSystemService(Context.TELEPHONY_SERVICE);
		return telephonyManager.getDataState() == TelephonyManager.DATA_CONNECTED;
 
	} 
} 
7
CodeRank
This code example shows how to use the following methods:getDataState
This code example shows how to use the following methods:getDataState
This code example shows how to use the following methods:getDataState
     * @param context a reference to Context or Activity 
     * @return true if data enabled. 
     */ 
    public static boolean   isEnable(Context context) {
        TelephonyManager tmanager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        return (tmanager.getDataState() == TelephonyManager.DATA_CONNECTED);
    } 
 
    /** 
     * Turn off mobile data. 
     * 
     * @param context a reference to Context or Activity 
     */ 
    public static void      disable(Context context) {
        switchState(context, false);
    } 
 
    /** 
     * Turn on mobile data. 
     * 
6
CodeRank
This code example shows how to use the following methods:getDataState
    public static boolean isConnectedToInternet(Context ctx) {
        TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
        WifiManager wm = (WifiManager) ctx.getSystemService(Context.WIFI_SERVICE);
        WifiInfo wi = wm.getConnectionInfo();
        return !((wi == null || WifiInfo.getDetailedStateOf(wi.getSupplicantState()) == NetworkInfo.DetailedState.IDLE) &&
                tm.getDataState() != TelephonyManager.DATA_CONNECTED);
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getDataState
    } 
 
    public boolean isConnectionEnabled() { 
        TelephonyManager telephonyManager = (TelephonyManager) context
                .getSystemService(Context.TELEPHONY_SERVICE);
        return telephonyManager.getDataState() == TelephonyManager.DATA_CONNECTED
                || telephonyManager.getDataState() == TelephonyManager.DATA_CONNECTING;
    } 
 
    public void enableConnection() { 
        changeConnection(true); 
    } 
 
    public void disableConnection() { 
        changeConnection(false); 
    } 
 
    public void switchConnection() { 
        if (isConnectionEnabled()) { 
            disableConnection(); 
5
CodeRank
This code example shows how to use the following methods:getDataState
		checkRoaming(); 
		checkConnectionState(); 
	} 
 
	private void checkConnectionState() { 
		int v = tm.getDataState();
		if (v != connection){
//			if(v == 2) 
				//sendNotification("telephonyConnectedON", true); 
//			else 
				//sendNotification("telephonyConnectedON", false); 
			connection = v;
		}		 
	} 
 
	private void checkRoaming() { 
		boolean r = tm.isNetworkRoaming();
//		if (r && (!roaming)) { 
//			sendNotification("roamingON", true); 
//			roaming = true; 
6
CodeRank
This code example shows how to use the following methods:getDataState
This code example shows how to use the following methods:getDataState
		TelephonyManager telephonyManager = (TelephonyManager) c
				.getSystemService(Context.TELEPHONY_SERVICE);
 
		if (mConnectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI)
				.isConnected()
				|| telephonyManager.getDataState() == TelephonyManager.DATA_CONNECTED)
			return true; 
		else 
			return false; 
		// return true; 
	} 
 
	public static void setTypeFaceForChilds(ViewGroup viewGroup,
			Typeface typeface) {
		final int childCount = viewGroup.getChildCount();
 
		for (int i = 0; i < childCount; i++) {
			View view = viewGroup.getChildAt(i);
 
			if (view instanceof ViewGroup) {
6
CodeRank
This code example shows how to use the following methods:getDataState
 } 
  
 private boolean checkConnectivityState(){ 
  final TelephonyManager telephonyManager = (TelephonyManager) mContext
    .getSystemService(Context.TELEPHONY_SERVICE);
  return telephonyManager.getDataState() == TelephonyManager.DATA_CONNECTED;
  
 } 
} 
6
CodeRank

Related TelephonyManager getDataState Questions & Answers:

getDataState Method Overview
Returns a constant indicating the current data connection state (cellular).
See Code Examples for other Android TelephonyManager Methods: