BlackBerry手机上Java程序如何判断当前手机使用的运营商网络名称?网路制式?...

本文介绍如何使用RadioInfoAPI获取并控制BlackBerry设备的网络连接状态,包括3GPP、CDMA、WiFi等网络类型的支持与切换。通过代码示例展示了如何实现对不同网络的激活与禁用,以及获取当前网络名称与运营商信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

你可以使用RadioInfo API了解相关信息,拿到的信息如下:

Network NameNetwork
9650 + China Telecom乱码((手机中文或者英文界面都是乱码,电信工作不给力啊)CDMA,
3GPP
GPRS
WiFi
9900 + China UnicomChina Unicom(手机英文界面)
中国联通

3GPP
GPRS
WiFi
9788 + China MobileCHINA MOBILE(手机英文界面)
中国移动

3GPP
GPRS
WiFi



import net.rim.device.api.system.*; import net.rim.device.api.ui.*; import net.rim.device.api.ui.component.*; import net.rim.device.api.ui.container.*; public class NetworkSample extends UiApplication { public static void main(String[] args) { NetworkSample app = new NetworkSample(); app.enterEventDispatcher(); } public NetworkSample() { pushScreen(new RadioControlScreen()); } } class RadioControlScreen extends MainScreen implements FieldChangeListener { boolean[] _intRadioOn = new boolean[3]; ButtonField _btn3G, _btnCDMA, _btniDEN, _btnWiFi; public RadioControlScreen() { VerticalFieldManager vfm = new VerticalFieldManager(Field.FIELD_HCENTER); LabelField label = new LabelField("Supported networks are: "); int wafs = RadioInfo.getSupportedWAFs(); if ((wafs & RadioInfo.WAF_3GPP) != 0 ) { label.setText(label.getText() + "3GPP;"); _btn3G = new ButtonField("3G Radio"); _btn3G.setChangeListener(this); vfm.add(_btn3G); } if ((wafs & RadioInfo.WAF_CDMA) != 0 ) { label.setText(label.getText() + "CDMA;"); _btnCDMA = new ButtonField("CDMA Radio"); _btnCDMA.setChangeListener(this); vfm.add(_btnCDMA); } if ((wafs & RadioInfo.WAF_WLAN) != 0 ) { label.setText(label.getText() + "WiFi;"); _btnWiFi = new ButtonField("WiFi Radio"); _btnWiFi.setChangeListener(this); vfm.add(_btnWiFi); } if ((wafs & RadioInfo.NETWORK_GPRS) != 0 ) { label.setText(label.getText() + "GPRS;"); } if ((wafs & RadioInfo.NETWORK_SERVICE_EVDO_REV0) != 0 ) { label.setText(label.getText() + "EVDO;"); } vfm.add(new LabelField("Your carrier name is " + RadioInfo.getCurrentNetworkName())); if ((wafs & RadioInfo.WAF_CDMA) != 0 ) { vfm.add(new LabelField("You are using China Telecom's CDMA network if you are in China, it support WAP 2.0")); } if (RadioInfo.getCurrentNetworkName().equalsIgnoreCase("CHINA MOBILE") ) { vfm.add(new LabelField("You are using China Mobile's network")); } if (RadioInfo.getCurrentNetworkName().equalsIgnoreCase("CHINA UNICOM") ) { vfm.add(new LabelField("You are using China Unicom's network")); } if (RadioInfo.getCurrentNetworkName().equalsIgnoreCase("中国移动") ) { vfm.add(new LabelField("You are using China Mobile中国移动 's network")); } if (RadioInfo.getCurrentNetworkName().equalsIgnoreCase("中国联通") ) { vfm.add(new LabelField("You are using China Unicom 中国联通's network")); } vfm.add(label); wafs = RadioInfo.getActiveWAFs(); if ((wafs & RadioInfo.WAF_3GPP) != 0 ) { _intRadioOn[0] = true; _btn3G.setLabel("3G Radio is on"); } if ((wafs & RadioInfo.WAF_CDMA) != 0 ) { _intRadioOn[1] = true; _btnCDMA.setLabel("CDMA Radio is on"); } if ((wafs & RadioInfo.WAF_WLAN) != 0 ) { _intRadioOn[2] = true; _btnWiFi.setLabel("WiFi Radio is on"); } add(vfm); /* StandardTitleBar tb = new StandardTitleBar(); tb.addTitle("Radio Control Demo"); tb.addSignalIndicator(); setTitleBar(tb); */ } public void fieldChanged(Field field, int context) { if (field instanceof ButtonField) { if(field == _btn3G) { if (_intRadioOn[0]) { Radio.deactivateWAFs(RadioInfo.WAF_3GPP); _btn3G.setLabel("3G Radio is off"); _intRadioOn[0] = false; } else { Radio.activateWAFs(RadioInfo.WAF_3GPP); _btn3G.setLabel("3G Radio is on"); _intRadioOn[0] = true; } } else if(field == _btnCDMA) { if (_intRadioOn[1]) { Radio.deactivateWAFs(RadioInfo.WAF_CDMA); _btnCDMA.setLabel("CDMA Radio is off"); _intRadioOn[1] = false; } else { Radio.activateWAFs(RadioInfo.WAF_CDMA); _btnCDMA.setLabel("CDMA Radio is on"); _intRadioOn[1] = true; } } else if(field == _btnWiFi) { if (_intRadioOn[2]) { Radio.deactivateWAFs(RadioInfo.WAF_WLAN); _btnWiFi.setLabel("WiFi Radio is off"); _intRadioOn[2] = false; } else { Radio.activateWAFs(RadioInfo.WAF_WLAN); _btnWiFi.setLabel("WiFi Radio is on"); _intRadioOn[2] = true; } } } } }


参考:

google:BlackBerry RadioInfo sample

Code sample: Controlling radios


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值