05-12-2011 07:26 AM
I am using following code to check either net connected is through wifi or wap but also want to check if 3g. But dont know how..
String checkNetwork(String url)
{
ServiceBook sb = ServiceBook.getSB();
ServiceRecord[] records = sb.findRecordsByCid("WPTCP");
String uid = null;
for(int i=0; i < records.length; i++)
{
//Search through all service records to find the
//valid non-Wi-Fi and non-MMS
//WAP 2.0 Gateway Service Record.
if (records[i].isValid() && !records[i].isDisabled())
{
if (records[i].getUid() != null && records[i].getUid().length() != 0)
{
if ((records[i].getUid().toLowerCase().indexOf("wifi" ) == -1) &&
(records[i].getUid().toLowerCase().indexOf("mms") == -1))
{
uid = records[i].getUid();
break;
}
}
}
}
if (uid != null)
{
//open a WAP 2 connection
url=url + ";ConnectionUID=" + uid;
}
else
{
// url = url + ";interface=wifi";
url = url + ";deviceside=true";
//Consider another transport or alternative action.
}
return url;
}I want to check for 3g also pls help how ?
Solved! Go to Solution.
05-12-2011 07:32 AM
05-13-2011 04:13 AM
I am using following code to check on device which network is currently working (Currently Wifi is on)
wafs=RadioInfo.getActiveWAFs();
if ((wafs & RadioInfo.WAF_3GPP) != 0 )
{
System.out.println("3G Radio is on");
}
if ((wafs & RadioInfo.WAF_CDMA) != 0 )
{
System.out.println("CDMA Radio is on");
}
if ((wafs & RadioInfo.WAF_WLAN) != 0 )
{
System.out.println("WiFi Radio is on");
}
else if ((wafs & RadioInfo.WAF_WLAN) != 0 )
{
return false;
}
else if ((wafs & RadioInfo.WAF_CDMA) != 0 )
{
return false;
}but the Wafs has 5 values and in this case its getting into two cases (wifi and 3g) pls help me
where i m wrong
05-13-2011 04:17 AM
05-13-2011 05:20 AM
Yes U right