androidcellular-network

Application crashes when connection switches to EDGE


I am developing an Android application that uses a socket connection to communicate with a server. The data that is transferred between the server and the Android device is in JSON format.

The application works fine on WiFi as well as HSPA mobile data connections. But when the connection type switches to EDGE, the application crashes.

Whenever the phone suddenly switches to EDGE, the following exception is captured...

[2012/06/03 18:47:26] ERROR - JSONManager.getJsonObjectFromStream : Unterminated string at character 202 of {"Messages":[{"RequestID":"c69421a4-34b1-4a55-828d-f0ab2aee80a6","OperationType":"GET","CategoryName":"Agent","RequestKey":"Revision","Params":null,"Channel":null,"EventID":null,"EventSource":null,"Even

The above is the exception reported to a log file that I have created to debug the application. As you can the see, the exception is captured and dealt with, but still the application crashes in a about. The error above is that JSON is incomplete. However, the this issue does not popup when connected to HSPA or WiFi.

Is there some sort of limitation with regard to the maximum length of data that can be transmitted over an EDGE connection?

What could I do to solve this problem?

If not, is there at least a way for me to detect when the phone changes its connection to an EDGE network?


Solution

  • This should help you: http://www.devdaily.com/java/jwarehouse/android/core/java/android/net/MobileDataStateTracker.java.shtml

    There is a lot in this code, so search for "case TelephonyManager.NETWORK_TYPE_EDGE:" and go from there.