I'm working on an Android application that will send MMS internally without using the native messaging app. I've been using the code from the native app that I found at https://android.googlesource.com as a guide and have managed to create a working prototype. However, I'm having a slight issue when trying to make the HTTP_Post when the phone is connected to Wifi.
In the code snippet below I request the MMS network feature and wait for the android.net.conn.CONNECTIVITY_CHANGE intent indicating the connection is active. I then request the NetworkInfo for TYPE_MOBILE and check that it is connected. This is where I hit the issue. If the wifi is connected, when I call info.isConnected() it returns false and the MMS HttpPost cannot be made as this post must be made through the 3G/GPRS connection.
ConnectivityManager.startUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE, "enableMMS");
//wait for android.net.conn.CONNECTIVITY_CHANGE intent
NetworkInfo info = connMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
if (!info.isConnected())
return;
The only way I can get it to work is by disconnecting the wifi at which point info.isConnected() returns true and I can go on to make the HttpPost successfully. But I don't think this is the correct way of performing this function as the native app doesn't seem to do this. From what I can see, the native messaging app's TransactionService.java uses an internal, deprecated class, NetworkConnectivityListener, to manage the connection but I can't see anything in its code that modifies the Wifi connection.
Has anyone had a similar issue to this or know of the correct way to work around it? I noticed in the ConnectivityManager documentation there's a connection type TYPE_MOBILE_MMS but I haven't tried this as it's only supported by devices running 2.2 and above and I want to be able to support devices running 1.6.
Any help would be most appreciated.