黑莓连接噩梦

发布于 2025-01-03 00:22:36 字数 4649 浏览 1 评论 0原文

我正忙于编写一个程序,将 GPS 坐标从手机传输到服务器,然后将坐标用于计算。但我在使用黑莓手机时总是碰壁。我已经构建了 Android 应用程序,它运行良好,但似乎无法联系真正的黑莓设备上的服务器。我已经在模拟器中测试了该应用程序,它运行良好,但是当我将其安装在真实手机上时,我没有收到手机请求。

我已经阅读了很多关于要附加在网址末尾的秘密字符串的内容,因此我改编了一些演示代码来获得第一个可用的传输,但仍然没有任何结果......

应用程序已签名并且我通常,然后通过 eclipse 调试或直接从 .jad 文件在设备上安装它,并允许应用程序所需的权限。

当前代码改编自 Blackberry SDK 中的 HTTP 连接演示。

你能看一下并给我一些指导吗?我在这里掉了太多头发......

持续运行的后端服务:

public void run() {

        System.out.println("Starting Loop");

        Criteria cr = new Criteria();
        cr.setHorizontalAccuracy(Criteria.NO_REQUIREMENT);
        cr.setVerticalAccuracy(Criteria.NO_REQUIREMENT);
        cr.setCostAllowed(false);
        cr.setPreferredPowerConsumption(Criteria.NO_REQUIREMENT);
        cr.setPreferredResponseTime(1000);
        LocationProvider lp = null;
        try {
            lp = LocationProvider.getInstance(cr);
        } catch (LocationException e) {
            System.out.println("*****************Exception" + e);
        }
        if (lp == null) {
            UiApplication.getUiApplication().invokeLater(new Runnable() {
                public void run() {
                    Dialog.alert("GPS not supported!");
                    return;
                }
            });
        } else {

            System.out
                    .println(lp.getState() + "-" + LocationProvider.AVAILABLE);

            switch (lp.getState()) {
            case LocationProvider.AVAILABLE:
                // System.out.println("Provider is AVAILABLE");
                while (true) {
                    Location l = null;
                    int timeout = 120;
                    try {
                        l = lp.getLocation(timeout);
                        final Location fi = l;

                        System.out.println("Got a Coordinate "
                                + l.getQualifiedCoordinates().getLatitude()
                                + ", "
                                + l.getQualifiedCoordinates().getLongitude());

                        System.out.println("http://" + Constants.website_base
                                + "/apis/location?device_uid=" + Constants.uid
                                + "&lat="
                                + l.getQualifiedCoordinates().getLatitude()
                                + "&lng="
                                + l.getQualifiedCoordinates().getLongitude());

                        if (!_connectionThread.isStarted()) {
                            fetchPage("http://"
                                    + Constants.website_base
                                    + "/apis/location?device_uid="
                                    + Constants.uid
                                    + "&lat="
                                    + l.getQualifiedCoordinates().getLatitude()
                                    + "&lng="
                                    + l.getQualifiedCoordinates()
                                            .getLongitude());
                        } else {
                            createNewFetch("http://"
                                    + Constants.website_base
                                    + "/apis/location?device_uid="
                                    + Constants.uid
                                    + "&lat="
                                    + l.getQualifiedCoordinates().getLatitude()
                                    + "&lng="
                                    + l.getQualifiedCoordinates()
                                            .getLongitude());
                        }

                        Thread.sleep(1000 * 60);

                    } catch (LocationException e) {
                        System.out.println("Location timeout");
                    } catch (InterruptedException e) {
                        System.out.println("InterruptedException"
                                + e.getMessage());
                    } catch (Exception ex) {
                        System.err.println(ex.getMessage());
                        ex.printStackTrace();
                    }
                }
            }
    }

我的连接是通过以下方式建立的:

ConnectionFactory connFact = new ConnectionFactory();
ConnectionDescriptor connDesc = connFact.getConnection(getUrl());

// Open the connection and extract the data.
try {
    // StreamConnection s = null;
    // s = (StreamConnection) Connector.open(getUrl());
    HttpConnection httpConn = (HttpConnection) connDesc.getConnection();
    /* Data is Read here with a Input Stream */

有什么想法吗?

I'm busy writing a Program that Transmits GPS Coordinates to a Server from a mobile phone where the coordinates are then used for calculations. But I'm constantly hitting a wall with blackberry. I have built the Android App and it works great but can't seem to contact the server on a real blackberry device. I have tested the application in a simulator and it works perfectly but when I install it on a real phone I get no request the phone.

I have read quite a bit about the secret strings to append at the end of the url so I adapted some demo code to get me the first available transport but still nothing ...

The Application is Signed and I normally then either install it by debugging through eclipse or directly on the device from the .jad file and allow the application the required permissions.

The current code was adapted from the HTTP Connection Demo in the Blackberry SDK.

Could you have a look and give me some direction. I'm losing too much hair here ...

The Backend Service that keeps running:

public void run() {

        System.out.println("Starting Loop");

        Criteria cr = new Criteria();
        cr.setHorizontalAccuracy(Criteria.NO_REQUIREMENT);
        cr.setVerticalAccuracy(Criteria.NO_REQUIREMENT);
        cr.setCostAllowed(false);
        cr.setPreferredPowerConsumption(Criteria.NO_REQUIREMENT);
        cr.setPreferredResponseTime(1000);
        LocationProvider lp = null;
        try {
            lp = LocationProvider.getInstance(cr);
        } catch (LocationException e) {
            System.out.println("*****************Exception" + e);
        }
        if (lp == null) {
            UiApplication.getUiApplication().invokeLater(new Runnable() {
                public void run() {
                    Dialog.alert("GPS not supported!");
                    return;
                }
            });
        } else {

            System.out
                    .println(lp.getState() + "-" + LocationProvider.AVAILABLE);

            switch (lp.getState()) {
            case LocationProvider.AVAILABLE:
                // System.out.println("Provider is AVAILABLE");
                while (true) {
                    Location l = null;
                    int timeout = 120;
                    try {
                        l = lp.getLocation(timeout);
                        final Location fi = l;

                        System.out.println("Got a Coordinate "
                                + l.getQualifiedCoordinates().getLatitude()
                                + ", "
                                + l.getQualifiedCoordinates().getLongitude());

                        System.out.println("http://" + Constants.website_base
                                + "/apis/location?device_uid=" + Constants.uid
                                + "&lat="
                                + l.getQualifiedCoordinates().getLatitude()
                                + "&lng="
                                + l.getQualifiedCoordinates().getLongitude());

                        if (!_connectionThread.isStarted()) {
                            fetchPage("http://"
                                    + Constants.website_base
                                    + "/apis/location?device_uid="
                                    + Constants.uid
                                    + "&lat="
                                    + l.getQualifiedCoordinates().getLatitude()
                                    + "&lng="
                                    + l.getQualifiedCoordinates()
                                            .getLongitude());
                        } else {
                            createNewFetch("http://"
                                    + Constants.website_base
                                    + "/apis/location?device_uid="
                                    + Constants.uid
                                    + "&lat="
                                    + l.getQualifiedCoordinates().getLatitude()
                                    + "&lng="
                                    + l.getQualifiedCoordinates()
                                            .getLongitude());
                        }

                        Thread.sleep(1000 * 60);

                    } catch (LocationException e) {
                        System.out.println("Location timeout");
                    } catch (InterruptedException e) {
                        System.out.println("InterruptedException"
                                + e.getMessage());
                    } catch (Exception ex) {
                        System.err.println(ex.getMessage());
                        ex.printStackTrace();
                    }
                }
            }
    }

My Connection is Made with:

ConnectionFactory connFact = new ConnectionFactory();
ConnectionDescriptor connDesc = connFact.getConnection(getUrl());

// Open the connection and extract the data.
try {
    // StreamConnection s = null;
    // s = (StreamConnection) Connector.open(getUrl());
    HttpConnection httpConn = (HttpConnection) connDesc.getConnection();
    /* Data is Read here with a Input Stream */

Any Ideas ?

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

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

发布评论

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

评论(1

忆伤 2025-01-10 00:22:36

想通了!

使用我在网上找到的函数来确定哪个;通过使用大量 Try / Catch 连接时使用的扩展。然后必须设置 Internet APN 设置。我在南非使用 Vodacom,因此 APN 是“互联网”,没有密码。

头发都快剩下了......

Figured it out!

Using a function I found online to determine which ; extension to use when connecting by using numerous Try / Catch. Then had to set the Internet APN settings. I'm in South-Africa using Vodacom so the APN is "Internet" with no Password.

Barely have hair left ....

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