如何正确构建HTTP连接后缀

发布于 2024-10-17 05:37:56 字数 1687 浏览 2 评论 0原文

我编写了使用 Google 地图反向地理编码获取位置名称的代码,例如: http://maps.google.com/maps/geo? json&ll=9.6,73.7

如何为上述 URL 添加适当的 HTTP 连接后缀?

我尝试了以下功能:

private static String getConnectionStringForGoogleMap(){
    String connectionString="";
    if(WLANInfo.getWLANState()==WLANInfo.WLAN_STATE_CONNECTED){
        connectionString="&interface=wifi";
    }   
     else if((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_MDS) == CoverageInfo.COVERAGE_MDS){
         connectionString = "&deviceside=false";
    }
        else if((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_DIRECT)==CoverageInfo.COVERAGE_DIRECT){
            String carrierUid=getCarrierBIBSUid();
            if(carrierUid == null) {
                connectionString = "&deviceside=true";
            }
            else{
                 connectionString = "&deviceside=false&connectionUID="+carrierUid + "&ConnectionType=mds-public";
                }

            }
     else if(CoverageInfo.getCoverageStatus() == CoverageInfo.COVERAGE_NONE)
        {

        }
    return connectionString;
    }

当我在模拟器中运行应用程序时,我创建如下 URL: http://maps.google.com/maps/geo?json&ll=9.6,73.7+getConnectionStringForGoogleMap();

但我遇到隧道异常,不知道下一步该怎么做。

此 URL 也会导致异常: http://maps.google.com/maps/geo?json&ll=9.6,73.7&deviceside=false&ConnectionType=mds-public

正如: http://maps.google.com/maps/geo?json&ll=9.6,73.7;deviceside=false;ConnectionType=mds-public

我很困惑如何才能使其正常工作。

I have written code to get a location name using Google Maps reverse geocoding, for example:
http://maps.google.com/maps/geo?json&ll=9.6,73.7

How can I add an appropriate HTTP connection suffix to the above URL?

I have tried the following function:

private static String getConnectionStringForGoogleMap(){
    String connectionString="";
    if(WLANInfo.getWLANState()==WLANInfo.WLAN_STATE_CONNECTED){
        connectionString="&interface=wifi";
    }   
     else if((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_MDS) == CoverageInfo.COVERAGE_MDS){
         connectionString = "&deviceside=false";
    }
        else if((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_DIRECT)==CoverageInfo.COVERAGE_DIRECT){
            String carrierUid=getCarrierBIBSUid();
            if(carrierUid == null) {
                connectionString = "&deviceside=true";
            }
            else{
                 connectionString = "&deviceside=false&connectionUID="+carrierUid + "&ConnectionType=mds-public";
                }

            }
     else if(CoverageInfo.getCoverageStatus() == CoverageInfo.COVERAGE_NONE)
        {

        }
    return connectionString;
    }

When I run the application in the simulator, I create the URL like this:
http://maps.google.com/maps/geo?json&ll=9.6,73.7+getConnectionStringForGoogleMap();

But I get a tunnel exception and am not sure what to do next.

This URL also leads to an exception:
http://maps.google.com/maps/geo?json&ll=9.6,73.7&deviceside=false&ConnectionType=mds-public

As does:
http://maps.google.com/maps/geo?json&ll=9.6,73.7;deviceside=false;ConnectionType=mds-public

I am confused about what to do to get this to work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(5

若能看破又如何 2024-10-24 05:37:56

您肯定需要分号 (;) 而不是与号 (&)。您想在模拟器上运行它吗?如果是这样,您是否正在运行 MDS 模拟器?这是在模拟器上使用 devicside=false 所必需的。

You definitely want semi-colons (;) and not ampersands (&). Are you tring to run this on the simulator? If so, do you have the MDS simulator running? That is required in order to use devicside=false on the simulator.

情痴 2024-10-24 05:37:56

尝试使用 Versatile Monkey 的网络助手类 找到 HTTP 连接的最佳路径并避免这些隧道异常。并使用正确的语法形成 URL。

Try using Versatile Monkey's networking helper class to find the best path for your HTTP connection and avoid those tunnel exceptions. And form the URL with the correct syntax.

场罚期间 2024-10-24 05:37:56

有一个 BlackBerry Java 开发论坛上有关于此的非常好的帖子,其中包含示例 HTTP 连接代码。

There is a very good posting about this on the BlackBerry Java development forum, complete with sample HTTP connection code.

仲春光 2024-10-24 05:37:56

如果您的目标是 OS5 及更高版本,则可以使用 连接工厂。这需要花费大量艰苦的工作来建立正确的连接类型。

If you are targeting OS5 and above you can use ConnectionFactory. This takes a lot of the hard work out of establishing the correct connection type.

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