CONNECTIVITY_SERVICE无法使用Sprint手机

时间:2012-11-14 15:44:54

标签: android

我正在尝试使用针对MMS的TYPE_MOBILE的startUsingNetworkFeature,每次我在Sprint手机上进行测试时,它只会启动WIFI服务。它在ATT和Verizon手机上运行良好(我在所有三个网络上都使用Galaxy Nexus作为我的测试手机)。

这是我的代码和相关的logcat输出:

    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:类型:mobile_mms [CDMA - EvDo rev。 A],状态:DISCONNECTED / IDLE,原因:(未指定),额外:(无),漫游:false,故障转移:false,isAvailable:true 11-14 10:41:12.951:V / main(2772):处理ConnectivityBroadcastReceiver.onReceive():NetworkInfo:类型:WIFI [],状态:CONNECTED / CONNECTED ,原因:(未指定), extra :( none),漫游:false,failover:false,isAvailable:true 11-14 10:41:12.951:V / main(2772):类型不是TYPE_MOBILE_MMS,保释

我也记录了TYPE_MOBILE_MMS的状态,仅供比较。我希望代码能够启动TYPE_MOBILE_MMS网络功能和广播接收器来接收该网络的网络变化事件,但它始终只是接收到wifi更改并且永远不会激活正确的网络。

Sprint手机有什么独特之处吗? 再次,这适用于ATT和Verizon,所有这些都在Galaxy Nexus手机上进行了最新更新。

更新:这是我的许可列表

  • “android.permission.ACCESS_NETWORK_STATE”

  • “android.permission.CHANGE_NETWORK_STATE”

更新2:在Sprint上使用Galaxy Nexus,而不是在Sprint上使用HTC Thunderbolt。 GNex在prefs中禁用了数据

HTC Thunderbolt上的

更新3:,每当我运行代码然后检查移动数据设置时,它会将移动网络显示为“因服务不可用而断开连接”。但是,当我强制关闭应用程序时,移动网络恢复正常?有关此代码的信息导致网络关闭HTC Thunderbolt。

更新4:我在测试期间看到了以下logcat输出,

11-14 14:49:35.866:V / main(1078):TYPE_MOBILE status NetworkInfo:type:mobile [CDMA - EvDo rev。 A],状态:DISCONNECTED / DISCONNECTED,原因:dataConnectionDenied ,额外:(无),漫游:false,故障转移:false,isAvailable:true 11-14 14:49:35.866:V / main(1078):TYPE_MOBILE_MMS状态NetworkInfo:type:mobile_mms [CDMA - EvDo rev。 A],状态:DISCONNECTED / IDLE,原因:psRestrictDisabled ,额外:(无),漫游:false,故障转移:false,isAvailable:true

似乎连接请求被拒绝,有人知道为什么会发生这种情况吗?

0 个答案:

没有答案