Feature #221
Utiliser le ConnectitManager
Start date:
11/26/2009
Due date:
% Done:
100%
Estimated time:
Description
Ca serait bien d'utiliser le ConnectivityManager du telephone afin de savoir si on acces ou non a une connexion, avant de lancer une tentative inutile.
Usefull Links :¶
Updated by Nikita Kozlov almost 15 years ago
Petit exemple d'un autre projet ...
public static boolean isWifi() { WifiManager wm = (WifiManager) mContext .getSystemService(Context.WIFI_SERVICE); WifiInfo wi = wm.getConnectionInfo(); if (wi != null) Log.i("SipUA:", "isFast() " + WifiInfo.getDetailedStateOf(wi.getSupplicantState()) + " " + cellAsu); if (wi != null && (WifiInfo.getDetailedStateOf(wi.getSupplicantState()) == DetailedState.OBTAINING_IPADDR || WifiInfo .getDetailedStateOf(wi.getSupplicantState()) == DetailedState.CONNECTED)) { on_wlan = PreferenceManager.getDefaultSharedPreferences(mContext) .getBoolean("wlan", false); return on_wlan; } on_wlan = false; return on_wlan; } public static boolean isUmts() { TelephonyManager tm = (TelephonyManager) mContext .getSystemService(Context.TELEPHONY_SERVICE); if (!PreferenceManager.getDefaultSharedPreferences(mContext) .getBoolean("3g", false)) return false; if (tm.getNetworkType() >= TelephonyManager.NETWORK_TYPE_UMTS) return true; return false; } public static boolean isEdge() { TelephonyManager tm = (TelephonyManager) mContext .getSystemService(Context.TELEPHONY_SERVICE); if (tm.getNetworkType() == TelephonyManager.NETWORK_TYPE_EDGE) return cellAsu >= minEdge; return false; }
Updated by Frédéric Barthéléry almost 15 years ago
Nikita Kozlov wrote:
Petit exemple d'un autre projet ...
[...]
Peut etre enormement simplifier vu que nous on veut juste savoir si il y a du reseau.
Updated by Nikita Kozlov almost 15 years ago
- Status changed from New to Feedback
- % Done changed from 0 to 100
Updated by Frédéric Barthéléry almost 15 years ago
- % Done changed from 100 to 90
Je pense que ca devrait plutot etre fait dans le service et non dans l'ui.
Updated by Nikita Kozlov almost 15 years ago
- % Done changed from 90 to 100
Add of an Intent receiver in the service.