Determine data signal strength

I know that it is possible to determine the type of data connection (WIFI / or cellular) via Android, but is it possible to determine the type and strength of cellular communication?

I have an application that downloads some images, and I found that on GPRS or 3G with a weak signal that this download process slows down the application is unacceptable. I want to say that if you have WIFI or a strong and fast data connection, download; otherwise, display the default replacement image.

Any clues on how to do this?

+4
source share
2 answers

How not to block the user interface thread and perform lengthy running tasks in the background thread, where do they belong?

Check out the AsyncTask link and the article on streaming calling Painless Thread .

Update: Ok, then find the ConnectivityManager man page that does exactly what you want.

Update2 : just realized what you wanted to know about signal strength. In this case, you need to find the SignalStrength class.

+2
source
  • The definition of radio engineering (network type) is simple:

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; } 
  • If you want to estimate the download time, you must measure the bandwidth in Kbps by opening, for example, a socket connection. But it's too complicated! I suggest you try uploading the image to AsyncTask anyway and set a timer limit of 5 seconds. If the download fails, stop the asintex and display the default linker image.
+2
source

All Articles