黑莓中所需的无线电未激活错误
我正在尝试从黑莓代码中获取一些网络服务。这是我正在使用的代码
public void execute(int method)
{
HttpConnection connection = null;
try
{
switch(method)
{
case GET:
{
String combinedParams = "";
if(!params.isEmpty())
{
combinedParams += "?";
for(int i=0;i<params.size();i++)
{
String[] nameValue = SplitString.split(params.elementAt(i).toString(), ",");
String paramString = nameValue[0] + "=" + nameValue[1];
if(combinedParams.length() > 1)
{
combinedParams += "&" + paramString;
}
else
{
combinedParams += paramString;
}
}
}
if(combinedParams.equals(""))
{
System.err.println("URL = "+url);
connection = (HttpConnection)Connector.open(url);
}
else
{
connection = (HttpConnection)Connector.open(url+combinedParams);
}
connection.setRequestMethod(HttpConnection.GET);
executeRequest(connection);
break;
}
case POST:
{
connection = (HttpConnection)Connector.open(url);
connection.setRequestMethod(HttpConnection.POST);
for(int i=0;i<headers.size();i++)
{
String[] nameValue = SplitString.split(params.elementAt(i).toString(), ",");
connection.setRequestProperty(nameValue[0], nameValue[1]);
}
if(getData()!= null)
{
OutputStream os = connection.openOutputStream();
os.write(getData().toString().getBytes());
os.flush();
}
executeRequest(connection);
break;
}
}
}
catch(Exception e)
{
System.err.println(e.getMessage());
e.printStackTrace();
}
}
一旦我运行此行,
connection = (HttpConnection)Connector.open(url);
我就会收到错误所需的无线电未激活
我的设备中没有任何SIM卡,但我已连接到wifi并且可以访问来自浏览器的其他网页。
导致此错误的可能原因是什么?
我已经尝试过这个链接和RadioInfo.getState( ) 在我的例子中是关闭的。
谢谢
I am trying to fetch some web services from blackberry code. Heres the code I am using
public void execute(int method)
{
HttpConnection connection = null;
try
{
switch(method)
{
case GET:
{
String combinedParams = "";
if(!params.isEmpty())
{
combinedParams += "?";
for(int i=0;i<params.size();i++)
{
String[] nameValue = SplitString.split(params.elementAt(i).toString(), ",");
String paramString = nameValue[0] + "=" + nameValue[1];
if(combinedParams.length() > 1)
{
combinedParams += "&" + paramString;
}
else
{
combinedParams += paramString;
}
}
}
if(combinedParams.equals(""))
{
System.err.println("URL = "+url);
connection = (HttpConnection)Connector.open(url);
}
else
{
connection = (HttpConnection)Connector.open(url+combinedParams);
}
connection.setRequestMethod(HttpConnection.GET);
executeRequest(connection);
break;
}
case POST:
{
connection = (HttpConnection)Connector.open(url);
connection.setRequestMethod(HttpConnection.POST);
for(int i=0;i<headers.size();i++)
{
String[] nameValue = SplitString.split(params.elementAt(i).toString(), ",");
connection.setRequestProperty(nameValue[0], nameValue[1]);
}
if(getData()!= null)
{
OutputStream os = connection.openOutputStream();
os.write(getData().toString().getBytes());
os.flush();
}
executeRequest(connection);
break;
}
}
}
catch(Exception e)
{
System.err.println(e.getMessage());
e.printStackTrace();
}
}
As soon as I run this line
connection = (HttpConnection)Connector.open(url);
I am getting the error Required radio is not active
I dont have any sim card in the device but I am connected to a wifi and I can access other web pages from the browser.
What could be the possible reason for this error?
I have tried this link and the RadioInfo.getState() is Off in my case.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
来自连接器上的文档:
这意味着您必须检测无线电是否关闭,如果是,您可以通过在 URL 中添加
interface=wifi
来尝试使用 Wi-Fi。正确的 URL 为:http://www.google.com;interface=wifi
From the docs on Connector:
What this means is that you'll have to detect if the radio is off, and if it is you can attempt to use Wi-Fi by adding
interface=wifi
to the URL. A proper URL would be:http://www.google.com;interface=wifi