我正在尝试将连接的WiFi的WiFi SSID与我想要连接的WiFi进行比较。我正在使用rad studio 10.2.3 c ++。所以我使用以下代码:
_di_JObject obj = SharedActivityContext()->getApplicationContext()->
getSystemService(TJContext::JavaClass->WIFI_SERVICE);
_di_JWifiManager wifiMng = TJWifiManager::Wrap(((_di_ILocalObject)obj)->
GetObjectID());
_di_JWifiInfo wifiInfo = wifiMng->getConnectionInfo();
String ssid = JStringToString(wifiInfo->getSSID()->toString());
//ive also tried the below code with no success
String ssid = wifiInfo->getSSID()->toString();
if(JStringToString(wifiInfo->getSSID()->equals("\"HomeWifi\"")))
{
ShowMessage("Connected to: "+JStringToString(wifiInfo->getSSID()));
}
else
{
ShowMessage("Not connected to: "+JStringToString(wifiInfo->getSSID()));
}
我在if语句中遇到错误。 错误:无法从'const char [12]'转换为'_di_JString'(又名'DelphiInterface')
请帮忙......
答案 0 :(得分:0)
我的问题的解决方案是
if((JStringToString(wifiInfo->getSSID()->toString())) == "\"" + tmpSSID + "\"")