Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Android™ Development

Reply
Regular Contributor
Posts: 92
Registered: ‎03-09-2013
My Device: bold 9800
My Carrier: blackberry

TELEPHONY_SERVICE for GPRS not working

Hello, I am using TELEPHONY_SERVICE for GPRS status.. But it is not working properly,i just want to switch to another activity when there is "No Gprs Found".. Please Help me out there..

 

final ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
                    final android.net.NetworkInfo wifi = connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
                    TelephonyManager tempManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
                        //int networkType = tempManager.getNetworkType();
                        
                    if (wifi.isAvailable()){
                        Intent Connectivity_intent = new Intent(MainActivity.this,MyConnectionActivity.class);
                            startActivity(Connectivity_intent);
                    }
                    
                    else if (tempManager.getNetworkType() == TelephonyManager.NETWORK_TYPE_GPRS){
                        Log.v("networkType", ""+tempManager.getNetworkType());
                        Intent Connectivity_intent = new Intent(MainActivity.this,MyConnectionActivity.class);
                            startActivity(Connectivity_intent);
                        }
                    else{
                        Intent noConnectivity_intent = new Intent(MainActivity.this,NoConnectivityMainActivity.class);
                            startActivity(noConnectivity_intent);    
     
                            finish();
                    }

Highlighted
Retired
Posts: 140
Registered: ‎04-19-2013
My Device: BlackBerry Z10

Re: TELEPHONY_SERVICE for GPRS not working

There's more than just one NETWORK_TYPE_* in TelephonyManager.  It's not valid to indicate there's no network connection if the network type is not GPRS.