gpt4 book ai didi

networking - 在 BlackBerry 上扫描可用的 Wi-Fi 网络

转载 作者:行者123 更新时间:2023-12-03 22:32:35 24 4
gpt4 key购买 nike

有没有RIM可用的 API 将有助于获取设备的可用网络服务列表或仅 Wi-Fi 网络列表,并为任何网络通信设置选定的网络接入点?

我的应用程序是否可以禁用 GPRS、WAP 等移动网络?

例子:
当应用程序启动时,它应该扫描 Wi-Fi 连接,即使设备上没有设置以前的 Wi-Fi 网络接入点,并列出可用的 Wi-Fi 连接。然后用户将选择合适的 Wi-Fi 连接来连接任何网络通信。在应用程序之外,任何 Internet 通信(如浏览器或任何其他应用程序)都应通过相同的选定 Wi-Fi 连接完成。扫描 Wi-Fi 和设置连接与 BlackBerry Wi-Fi 设置几乎相似。

我希望为 BlackBerry OS 4.5、4.7 和 5.0 执行此操作。

更新

问题是我正在通过应用程序寻找 Wi-Fi 扫描。这就像通过该应用程序,我能够扫描可用的 Wi-Fi 接入点或热点,并通过将其选择到设备来设置接入点之一,然后连接到它进行通信。

基本上就像,我们如何在BlackBerry 的“管理连接”中设置Wi-Fi 连接?我必须通过应用程序做类似的事情。

从一些BlackBerry论坛我了解到OS v5.0中有一个包,即一个net.rim.device.api.wlan.hotspot包来获取Wi-Fi热点.但是经过长时间的搜索,我没有找到任何示例或太多解释。因为我试图通过查看其 API 文档来实现,但我没有成功。

如果您对此有任何想法或任何示例代码,那将非常有帮助。

最佳答案

好吧,要扫描应用程序的所有可用网络,您可以使用 NetworkDiagnostic tool来自 RIM。

可以在 How to reliably establish a network connection on any BlackBerry device 中找到用于扫描手机连接并获得最佳连接字符串的另一段代码。 ,

/**
* 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;
}

关于networking - 在 BlackBerry 上扫描可用的 Wi-Fi 网络,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2992052/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com