黑莓中所需的无线电未激活错误

发布于 2024-12-19 12:39:27 字数 2995 浏览 4 评论 0原文

我正在尝试从黑莓代码中获取一些网络服务。这是我正在使用的代码

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

明明#如月 2024-12-26 12:39:27

来自连接器上的文档

Wi-Fi 支持

通过设置接口参数即可建立Wi-Fi连接。这仅适用于直接 TCP/UDP 连接。

interface:如果 interface=wifi 参数附加到 URI 字符串值的末尾,则打开 Wi-Fi 套接字连接。

这意味着您必须检测无线电是否关闭,如果是,您可以通过在 URL 中添加 interface=wifi 来尝试使用 Wi-Fi。正确的 URL 为:http://www.google.com;interface=wifi

From the docs on Connector:

Wi-Fi Support

Wi-Fi connection can be established by setting the interface parameter. This only works with direct TCP/UDP connections.

interface: If the interface=wifi parameter is appended to the end of the URI string value, a Wi-Fi socket connection is opened.

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文