开发者

Find Android GPRS status

开发者 https://www.devze.com 2023-03-25 19:12 出处:网络
I have sales application.This application used by sales rep. So We can\'t make sure anywhere wifi or 3G available. So I have to check the GPRS connection. & Sales rep need to do the replication.If

I have sales application.This application used by sales rep. So We can't make sure anywhere wifi or 3G available. So I have to check the GPRS connection. & Sales rep need to do the replication.If开发者_Go百科 the GPRS strength is higher than particular rate then allow to do the replication.

How to find out GPRS is enable ? I want to call webservice.First It check WIFI,3G,then GPRS.

For WIFI, 3G I did like this

 ConnectivityManager manager = (ConnectivityManager) getSystemService(DownlaodTableActivity.CONNECTIVITY_SERVICE);
    Boolean is3g = manager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).isConnectedOrConnecting();
    Boolean isWifi = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).isConnectedOrConnecting();
    if(isWifi ){ ..... } else if(is3g){ ..... } else if(GPRS) {....}

For GPRS I have done like: https://stackoverflow.com/questions/6898568/how-to-get-the-gsm-strength-outside-method

Please anybody tell me how to take the GPRS connection.

(Sales rep must use GPRS connection available phone.)


I am not sure if you can do this all the time, but if user is connected on data network you can check current network type as GPRS or not using following code:

TelephonyManager mgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
int networkType = mgr.getNetworkType()

and if it is gprs the value will be TelephonyManager.NETWORK_TYPE_GPRS

0

精彩评论

暂无评论...
验证码 换一张
取 消