如何从3克检测网络类型转换成H + Android上 [英] how to detect network type change from 3g to H+ on Android
问题描述
与connectivitymanager和广播接收器,我能够得到连接和断开事件解释埃里克这里职位>
with connectivitymanager and broadcast receiver I'm able to get connection and disconnection events as explained Eric's post here
我想知道的是当网络连接类型的变化。
例如:3G到H +,反之亦然。我看到里面有的onReceive(..)时,这个变化发生的...
What I would like to know is the change in type while network is being connected. Ex: 3G to H+ and vice versa.. I see there are no events inside OnReceive(..) when this change happens...
用户案例清晰:
第一步:3G连接被启用,以广播接收的事件(BCR)和加工
第二步:发起呼叫,在从3G到H +连接的变化,但在BCR任何情况
User case for clarity: step1: 3G connection is enabled, events received in broadcast(BCR) and processed step2: start a call, changes in connection from 3G to h+ but no event in BCR.
预计产量:预计BCR的事件时有从3G切换到H +或边缘...
expected output: expect an event in BCR when there is change from 3G to h+ or Edge...
推荐答案
在这里,switch语句,你可以做一定的TAKS。一个线程可以拨打以下code和照看网络。
Here, on switch statement you can do certain taks. A Thread can call the following code and keep an eye on network.
TelephonyManager teleMan =
(TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
int networkType = teleMan.getNetworkType();
switch (networkType)
{
case 7:
textV1.setText("1xRTT");
break;
case 4:
textV1.setText("CDMA");
break;
case 2:
textV1.setText("EDGE");
break;
case 14:
textV1.setText("eHRPD");
break;
case 5:
textV1.setText("EVDO rev. 0");
break;
case 6:
textV1.setText("EVDO rev. A");
break;
case 12:
textV1.setText("EVDO rev. B");
break;
case 1:
textV1.setText("GPRS");
break;
case 8:
textV1.setText("HSDPA");
break;
case 10:
textV1.setText("HSPA");
break;
case 15:
textV1.setText("HSPA+");
break;
case 9:
textV1.setText("HSUPA");
break;
case 11:
textV1.setText("iDen");
break;
case 13:
textV1.setText("LTE");
break;
case 3:
textV1.setText("UMTS");
break;
case 0:
textV1.setText("Unknown");
break;
}
更新
http://developer.android.com/reference/android/content/ BroadcastReceiver.html
<一个href=\"http://stackoverflow.com/questions/2294971/intent-action-for-network-events-in-android-sdk\">Intent在Android SDK中网络事件采取行动。
这篇关于如何从3克检测网络类型转换成H + Android上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!