ams*_*ddh 3 networking blackberry gprs wifi
是否有任何RIM API可用于获取可用网络服务列表或仅用于设备的Wi-Fi网络并为任何网络通信设置选定的网络接入点?
我的应用程序是否可以禁用GPRS,WAP等移动网络?
示例:
启动应用程序时,即使设备上没有设置先前的Wi-Fi网络接入点,也应扫描Wi-Fi连接,并列出可用的Wi-Fi连接.然后,用户将选择适当的Wi-Fi连接以进行任何网络通信.在应用程序之外,任何Internet通信(如浏览器或任何其他应用程序)都应通过相同的选定Wi-Fi连接完成.扫描Wi-Fi并设置连接几乎与BlackBerry Wi-Fi Setup相似.
我希望为BlackBerry OS 4.5,4.7和5.0执行此操作.
更新
问题是我正在通过应用程序寻找Wi-Fi扫描.就像通过应用程序一样,我能够扫描可用的Wi-Fi接入点或热点,并通过选择一个接入点来设置它,然后连接到它以进行通信.
基本上就是这样,我们如何在BlackBerry的"管理连接"中设置Wi-Fi连接?我必须通过应用程序做类似的事情.
从一些黑莓论坛我发现OS v5.0中有一个软件包,即net.rim.device.api.wlan.hotspot软件包来获取Wi-Fi热点.但经过长时间的搜索,我没有找到任何示例或解释.正如我试图通过查看其API文档来实现,但我没有成功.
如果您对此或任何示例代码有任何想法,那将非常有帮助.
那么,要扫描应用程序的所有可用网络,您可以使用RIM 的NetworkDiagnostic工具.
可以在如何在任何BlackBerry设备上可靠地建立网络连接中找到用于扫描您的电话连接并获得最佳连接字符串的另一段代码,
/**
* Determines what connection type to use and returns the necessary string to use it.
* @return A string with the connection info
*/
private static String getConnectionString()
{
// This code is based on the connection code developed by Mike Nelson of AccelGolf.
// http://blog.accelgolf.com/2009/05/22/blackberry-cross-carrier-and-cross-network-http-connection
String connectionString = null;
// Simulator behavior is controlled by the USE_MDS_IN_SIMULATOR variable.
if (DeviceInfo.isSimulator())
{
if (UploaderThread.USE_MDS_IN_SIMULATOR)
{
logMessage("Device is a simulator and USE_MDS_IN_SIMULATOR is true");
connectionString = ";deviceside=false";
}
else
{
logMessage("Device is a simulator and USE_MDS_IN_SIMULATOR is false");
connectionString = ";deviceside=true";
}
}
// Wi-Fi is the preferred transmission method.
else if (WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED)
{
logMessage("Device is connected via Wifi.");
connectionString = ";interface=wifi";
}
// Is the carrier network the only way to connect?
else if ((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_DIRECT) == CoverageInfo.COVERAGE_DIRECT)
{
logMessage("Carrier coverage.");
String carrierUid = getCarrierBIBSUid();
if (carrierUid == null)
{
// Has carrier coverage, but not BIBS. So use the carrier's TCP network
logMessage("No Uid");
connectionString = ";deviceside=true";
}
else
{
// otherwise, use the Uid to construct a valid carrier BIBS request
logMessage("uid is: " + carrierUid);
connectionString = ";deviceside=false;connectionUID="+carrierUid + ";ConnectionType=mds-public";
}
}
// Check for an MDS connection instead (BlackBerry Enterprise Server).
else if ((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_MDS) == CoverageInfo.COVERAGE_MDS)
{
logMessage("MDS coverage found");
connectionString = ";deviceside=false";
}
// If there is no connection available abort to avoid bugging the user unnecssarily.
else if (CoverageInfo.getCoverageStatus() == CoverageInfo.COVERAGE_NONE)
{
logMessage("There is no available connection.");
}
// In theory, all bases are covered so this shouldn't be reachable.
else
{
logMessage("no other options found, assuming device.");
connectionString = ";deviceside=true";
}
return connectionString;
}
/**
* Looks through the phone's service book for a carrier provided BIBS network
* @return The uid used to connect to that network.
*/
private static String getCarrierBIBSUid()
{
ServiceRecord[] records = ServiceBook.getSB().getRecords();
int currentRecord;
for (currentRecord = 0; currentRecord < records.length; currentRecord++)
{
if (records[currentRecord].getCid().toLowerCase().equals("ippp"))
{
if (records[currentRecord].getName().toLowerCase().indexOf("bibs") >= 0)
{
return records[currentRecord].getUid();
}
}
}
return null;
}
Run Code Online (Sandbox Code Playgroud)