Reputation: 908
I know that it's possible to determine the data connection type (WIFI/or cellular) through Android, but is it possible to determine the cellular connection type and strength?
I have an app that downloads some images and I have found that on GPRS or on 3G with weak signal that this download process slows up the app unacceptably. What I want to do is say that if you have either WIFI or a strong and fast data connection then download; otherwise display a default placeholder image.
Any clues on how to do this?
Upvotes: 4
Views: 3404
Reputation: 41
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
int nt = tm.getNetworkType();
switch (nt) {
case 1: return GPRS;
case 2: return EDGE;
case 3: return UMTS;
case 8: return HSDPA;
case 9: return HSUPA;
case 10:return HSPA;
default:return UNKNOWN;
}
Upvotes: 3
Reputation: 39604
How about not blocking the UI thread and running long running tasks in a background thread where they belong to?
Look up the reference on AsyncTask and the article on threading called Painless Threading.
Update: Alright then lookup the reference page on ConnectivityManager which does just what you want.
Update2: Just realized that you wanted to know about the signal strength. In that case you need to lookup the SignalStrength class.
Upvotes: 2