黑莓基于位置的服务 [英] blackberry location-based services

查看:295
本文介绍了黑莓基于位置的服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以请告诉我如何与黑莓基于位置的服务工作?
我正在为黑莓手机应用程序的项目。我从来没有过黑莓和我没有与任何供应商(只是有3 SIM卡和移动设备9000 OS 4.6)的合同。

Can anyone please inform me how to work with blackberry location-based services? i am working on a project for a blackberry mobile application. i never had a blackberry before and i dont have a contract with any provider (just have a sim card from 3 and mobile device 9000 OS 4.6).

在该项目目前我正在试图使用下面的code,以获取当前位置(起点)和目标位置(端点)的坐标。它的工作原理就好在模拟器上,但是,从设备什么都没有。如果我有一个供应商或什么合同?而做到这一点只需要GPS或上网,或同时工作?

In the project i am currently trying to use the following code in order to retrieve the coordinates of current location (startpoint) and destination location (endpoint). It works just fine on the simulator but on the device nothing. Should i have a contract with a provider or something? and does this need just GPS or internet, or both to work?

code:

String destination = "London";

final Landmark[] landmarks = Locator.geocode(destination.replace('\n', ' '), null);
Coordinates endPoint = landmarks[0].getQualifiedCoordinates();
// Get a location provider.
LocationProvider provider = LocationProvider.getInstance(null);
if (provider == null)
{
    throw new IllegalStateException("No LocationProvider Available!!");
}
// Try to fetch the current location and get the coordinates of the current location.
Coordinates startPoint = provider.getLocation(-1).getQualifiedCoordinates();

double destiinationlatitude = endPoint.getLatitude();
double currentlatitude = startPoint.getLatitude();

感谢您提前

推荐答案

要在任何版本上获得GPS位置之前的5.0,你必须实例化这个事情

To get the GPS location on any version prior to 5.0 you have to instantiate this things


  1. 标准

  2. 位置提供商

  3. 位置对象(与位置提供完成)

下面是实例化的东西:

Criteria criteria = null;
LocationProvider provider = null;
javax.microedition.location.Location location = null;

之后,你必须分配值的标准,使用标准得到LocationProvider的实例,并使用LocationProvider得到位置。

After that you must assign values to the Criteria, get the instance of the LocationProvider using the criteria and get the Location using the LocationProvider.

criteria = new Criteria();
criteria.setPreferredPowerConsumption(Criteria.POWER_USAGE_HIGH);
criteria.setHorizontalAccuracy(50);
criteria.setVerticalAccuracy(50);
criteria.setCostAllowed(true);
provider = LocationProvider.getInstance(criteria);
location = provider.getLocation(5);

请注意,该标准将确定是否使用GPS,WIFI辅助位置或蜂窝基站的位置,更多信息在这里的标准设置:的http://www.blackberry.com/developers/docs/4.5.0api/javax/microedition/location/Criteria.html

Note that the Criteria will determine if you use GPS, Wifi assisted location or Cellsite location, more info on the criteria setting here: http://www.blackberry.com/developers/docs/4.5.0api/javax/microedition/location/Criteria.html

之后,得到的坐标调用方法:location.getQualifiedCoordinates()

After that, to get the coordinates you call the method: location.getQualifiedCoordinates()

这就是那个......你应该从一个单独的线程调用它。而且实际位置管理code应该是一个try-catch块上,但IDE会帮你。

And that's that... you should call this from a separate thread. And also the actual location management code should be on a try-catch block but the IDE will help you with that.

这篇关于黑莓基于位置的服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆