0

I have created an android application which user Http Post and Get calls to read and write data from web server. Nothing too flashy also. My phone/SIM has 4G. Every time the app tries to connect, thing go slow and most of the time the app crashes. So I changed settings to GSM only. Guess what? The app works much better. What could be the possible reasons for it?

manlio
  • 18,345
  • 14
  • 76
  • 126
SoH
  • 2,180
  • 2
  • 24
  • 53
  • Can you at least post the Log/stack trace of that crash here? How can we know without having any knowledge about your app? – YuDroid Jul 31 '12 at 06:03
  • The problem is occurring at a client's phone :( That is why I had to post a very vague question. I am using wifi connection and it works perfectly. – SoH Jul 31 '12 at 06:05
  • Have you given connection priorities in your application? Give preference in the order of their availability, i.e. selecting very first WIFI, then SIM card connections, whatever they are, either 3G/4G and so on.. – YuDroid Jul 31 '12 at 06:37

1 Answers1

0

Use the following method in order to detect all available type of networks at your client's disposal :

public static boolean checkNetworkRechability(Context context) {
        Boolean bNetwork = false;
        ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);

        for (NetworkInfo networkInfo : connectivityManager.getAllNetworkInfo()) {
            int netType = networkInfo.getType();
            int netSubType = networkInfo.getSubtype();

            if (netType == ConnectivityManager.TYPE_WIFI) {
                bNetwork = networkInfo.isConnected();
                if (bNetwork == true)
                    break;
            } else if (netType == ConnectivityManager.TYPE_MOBILE && netSubType != TelephonyManager.NETWORK_TYPE_UNKNOWN) {
                bNetwork = networkInfo.isConnected();
                if (bNetwork == true)
                    break;
            } else {
                bNetwork = false;
            }
        }
        if (!bNetwork) {
            Log.i(TAG, "You are not in network");
        }
        Log.i(TAG, "bNetwork : " + bNetwork);
        return bNetwork;
    }
YuDroid
  • 1,599
  • 5
  • 22
  • 44