I'm trying to use the startUsingNetworkFeature for TYPE_MOBILE for MMS and everytime I test on a Sprint phone it just starts the WIFI service instead. It works fine on ATT and Verizon phones (I use Galaxy Nexus for my test phones on all three networks).
Here's my code and the associated logcat output:
public class main extends FragmentActivity {
private static final String TAG = "main";
private ConnectivityManager mConnMgr;
private ConnectivityBroadcastReceiver mReceiver;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mConnMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
mReceiver = new ConnectivityBroadcastReceiver();
beginConnectivity();
}
private int beginConnectivity() {
int result = mConnMgr.startUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE, PhoneEx.FEATURE_ENABLE_MMS);
Log.v(TAG, "beginMmsConnectivity: result=" + result);
return result;
}
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
registerReceiver(mReceiver, intentFilter);
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
unregisterReceiver(mReceiver);
}
private class ConnectivityBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
Log.w(TAG, "ConnectivityBroadcastReceiver.onReceive() action: " + action);
NetworkInfo networkInfo = (NetworkInfo) intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
NetworkInfo mmsNetworkInfo = mConnMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
Log.v(TAG, "" + mmsNetworkInfo);
Log.v(TAG, "Handle ConnectivityBroadcastReceiver.onReceive(): " + networkInfo);
// Check availability of the mobile network.
if ((networkInfo == null) || (networkInfo.getType() != ConnectivityManager.TYPE_MOBILE_MMS)) {
Log.v(TAG, " type is not TYPE_MOBILE_MMS, bail");
return;
}
if (!networkInfo.isConnected()) {
Log.v(TAG, " TYPE_MOBILE_MMS not connected, bail");
}
return;
}
};
}
11-14 10:41:12.951: V/main(2772): NetworkInfo: type: mobile_mms[CDMA - EvDo rev. A], state: DISCONNECTED/IDLE, reason: (unspecified), extra: (none), roaming: false, failover: false, isAvailable: true 11-14 10:41:12.951: V/main(2772): Handle ConnectivityBroadcastReceiver.onReceive(): NetworkInfo: type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified), extra: (none), roaming: false, failover: false, isAvailable: true 11-14 10:41:12.951: V/main(2772): type is not TYPE_MOBILE_MMS, bail
I log the status of the TYPE_MOBILE_MMS as well, just for comparison. I expect the code to start the TYPE_MOBILE_MMS network feature and the broadcast receiver to receive the network change event for that network, but it always just picks up the wifi change and never activates the correct network.
Is there something unique about Sprint phones? Again, this works fine on ATT and Verizon, all on Galaxy Nexus phones with the latest update.
update: here is my permission list
"android.permission.ACCESS_NETWORK_STATE"
"android.permission.CHANGE_NETWORK_STATE"
update 2: working on Galaxy Nexus on Sprint, but not HTC Thunderbolt on Sprint. The GNex had data disabled in the prefs
update 3: on the HTC Thunderbolt, whenever I run the code and then check the mobile data settings it shows the mobile network as "disconnected because service is unavailable". However, when I force close the app the mobile network returns to normal? Something about this code is causing the the network to turn off on the HTC Thunderbolt.
update 4: I'm seeing the following logcat output during my testing,
11-14 14:49:35.866: V/main(1078): TYPE_MOBILE status NetworkInfo: type: mobile[CDMA - EvDo rev. A], state: DISCONNECTED/DISCONNECTED, reason: dataConnectionDenied, extra: (none), roaming: false, failover: false, isAvailable: true 11-14 14:49:35.866: V/main(1078): TYPE_MOBILE_MMS status NetworkInfo: type: mobile_mms[CDMA - EvDo rev. A], state: DISCONNECTED/IDLE, reason: psRestrictDisabled, extra: (none), roaming: false, failover: false, isAvailable: true
It seems like the connection request is being denied, does anyone know why this might be happening?