【问题标题】:Newest Quickblox SDK for Android: Get nearby locations does not work适用于 Android 的最新 Quickblox SDK:获取附近位置不起作用
【发布时间】:2014-09-10 14:26:54
【问题描述】:

我使用 Quickblox SDK for Android 已经有一段时间了。但是,新的 SDK 库使我的一些代码无法正常工作。具体来说,我创建了位置列表。然后我尝试搜索附近的位置,提供当前位置和半径。

  getLocationsBuilder.setCurrentPosition(qbLocation.getLatitude(),
  qbLocation.getLongitude());

  getLocationsBuilder.setRadius(point.getLatitude(),
          point.getLongitude(), (float) 5.0);



    GeoPoint point = new GeoPoint(qbLocation.getLatitude(),
            qbLocation.getLongitude());

但是,我得到的结果是格式不正确。

'{"errors":{"current_position":["应该在 GeoPoint 格式","应设置半径"]}}'

这是我的全部代码:

    Log.d(TAG,
            "update location is " + point.getLatitude() + " "
                    + point.getLongitude());

    QBLocationRequestBuilder getLocationsBuilder = new QBLocationRequestBuilder();
    getLocationsBuilder.setPage(1);
    getLocationsBuilder.setPerPage(100);
    getLocationsBuilder.setLastOnly();

    getLocationsBuilder.setCurrentPosition(qbLocation.getLatitude(), qbLocation.getLongitude());

    getLocationsBuilder.setRadius(point.getLatitude(),
    point.getLongitude(), (float) 5.0);

    int unixTime = (int) (System.currentTimeMillis() / 1000L - 1000);
    getLocationsBuilder.setMinCreatedAt(unixTime);

    // getLocationsBuilder.setSort(SortField.DISTANCE);

    QBLocations.getLocations(getLocationsBuilder, new QBEntityCallback<ArrayList<QBLocation>>() {
        @Override
        public void onSuccess(ArrayList<QBLocation> qbLocations, Bundle bundle) {
            ArrayList<String> card_ids = new ArrayList<String>();
            for (QBLocation location : qbLocations) {
                Log.d(TAG, "locations nearby : " + location);
                card_ids.add(location.getStatus()); // status is card_id
            }
            getCards(card_ids);
        }

        @Override
        public void onSuccess() {

        }

        @Override
        public void onError(List<String> strings) {

        }
    });

我可以搜索所有位置,并获得我想要的位置,但这并不像使用 SDK 那样优雅。

如果我只是将 Quickblox SDK 替换为早期版本,它就可以正常工作。

【问题讨论】:

  • 另外,当我只搜索所有位置并且只有一个结果时,SDK 崩溃告诉 QBCustomObject 不能转换为 QBEntityLimited

标签: android geolocation android-location quickblox


【解决方案1】:

看起来它在 1.2.4 中已修复

http://quickblox.com/developers/Android#Framework_changelog:

您使用哪个版本?

【讨论】:

  • 我认为它适用于 SDK 1.2.4。但我想使用最新的 API,并且已经重写了我的程序和 QuickBlox 调用以支持新的回调。只有位置不起作用。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-02-28
  • 2018-03-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多