×
Namespaces

Variants
Actions
(Difference between revisions)

通过Cell-ID获取位置信息

From Nokia Developer Wiki
Jump to: navigation, search
max.chen (Talk | contribs)
(Max.chen -)
hamishwillee (Talk | contribs)
m (Hamishwillee - Bot addition of Template:ArticleMetaData)
(2 intermediate revisions by one user not shown)
Line 1: Line 1:
[[Category:Sensor]][[Category:Security]][[Category:Lang-Chinese]]
+
{{ArticleMetaData
 +
|sourcecode=[[Media:CellID_com.nokia.mid.location.LocationUtil.zip]]  
 +
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
 +
|devices= <!-- Devices tested against - e.g. ''devices=Nokia 6131 NFC, Nokia C7-00'') -->
 +
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
 +
|platform= <!-- Compatible platforms - e.g. Symbian^1 and later, Qt 4.6 and later -->
 +
|devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) -->
 +
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
 +
|signing=<!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer -->
 +
|capabilities=<!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
 +
|keywords= <!-- APIs, classes and methods (e.g. QSystemScreenSaver, QList, CBase -->
 +
|id= <!-- Article Id (Knowledge base articles only) -->
 +
|language=Lang-Chinese
 +
|translated-by= <!-- [[User: XXXXX]] -->
 +
|translated-from-title=<!-- Title only -->
 +
|translated-from-id= <!-- Id of translated revision -->
 +
|review-by=<!-- After re-review: [[User:username]] -->
 +
|review-timestamp=<!-- After re-review: YYYYMMDD -->
 +
|update-by=<!-- After significant update: [[User:username]]-->
 +
|update-timestamp=<!-- After significant update: YYYYMMDD -->
 +
|creationdate=20110626
 +
|author=[[User:Max.chen]]
 +
}}[[Category:Lang-Chinese]][[Category:Series 40]][[Category:Java ME]][[Category:Location]]
 
== C2系列手机介绍 ==
 
== C2系列手机介绍 ==
 
2011年6月21日,第11届诺基亚年度盛会NokiaConnection在新加坡著名地标滨海湾金沙酒店(MarinaBay)开幕。会上诺基亚执行副总裁Mary McDowell发布三款C2系列新机C2-02、C2-03与C2-06。
 
2011年6月21日,第11届诺基亚年度盛会NokiaConnection在新加坡著名地标滨海湾金沙酒店(MarinaBay)开幕。会上诺基亚执行副总裁Mary McDowell发布三款C2系列新机C2-02、C2-03与C2-06。

Revision as of 06:44, 10 November 2011

WP Metro Icon Chinese.png
Article Metadata

代码示例
兼容于
平台:
Series 40

文章
max.chen 在 26 Jun 2011 创建
最后由 hamishwillee 在 10 Nov 2011 编辑

Contents

C2系列手机介绍

2011年6月21日,第11届诺基亚年度盛会NokiaConnection在新加坡著名地标滨海湾金沙酒店(MarinaBay)开幕。会上诺基亚执行副总裁Mary McDowell发布三款C2系列新机C2-02、C2-03与C2-06。

“这三款手机都能够为消费者带来市场上一流的上网、地图和信息体验,还同时提供触摸屏和键盘两种选择,让操作界面变得更加简便易上手。用户还可以选择双卡或单卡版本,让这三款手机在同类产品中极具竞争力。”MaryMcDowell表示。

本次C2系列的产品组合包括双卡手机与单卡手机,触键双控,能够为S40用户带来全新的、先进的互联网与地图体验。三款手机均配有针对S40系列的全新诺基亚地图,预装当地地图和兴趣点。用户可以在离线的情况下浏览地图并规划路线,从而省去通过网络下载地图的成本。

600-nokia-c2-02 closed.png

诺基亚C2-02

JSR179 Location API

JavaME 规范中定义了JSR179 Location API。这个包中涵盖了大量的用于获取位置信息的类。在此基础上,诺基亚又增加了Location API Appendix作为对JSR179的扩展。这个包只包含了一个类:

com.nokia.mid.location.LocationUtil

LocationUtil类也只定义了一个静态方法:

static LocationProvider  
getLocationProvider(int[] preferredMethods, java.lang.String parameters)

目前,参数preferredMethods的取值只有下面4组,而对于C2系列手机只能通过Cell-Id取得位置,所以也只能去第一组值。其他三组都不适用于C2系列手机。

  • (MTA_ASSISTED | MTE_CELLID | MTE_SHORTRANGE | MTY_NETWORKBASED) - Online CellID and/or WLAN
  • (MTA_ASSISTED | MTE_SATELLTITE | MTY_TERMINALBASED) - Assisted GPS
  • (MTA_UNASSISTED | MTE_SATELLITE | MTY_TERMINALBASED) - Standalone GPS
  • (MTA_UNASSISTED | MTE_CELLID | MTY_TERMINALBASED) - Offline CellID

第二个参数parameters是为了以后扩展之用,目前取值只能是null。

以下代码演示了如何利用LocationUtil和JSR179 Location API获取经纬度的信息:

try {                    
//MTA_ASSISTED Location method is assisted by the other party
//MTE_CELLID Location method Cell-ID for cellular
//MTY_NETWORKBASED Location method is of type network based.
int[] methods = {(Location.MTA_ASSISTED | Location.MTE_CELLID | Location.MTY_NETWORKBASED)}; // works
LocationProvider lp = LocationUtil.getLocationProvider(methods, null);
Location loc = lp.getLocation(-1);
Coordinates coords = loc.getQualifiedCoordinates();
lat = coords.getLatitude(); //double
lng = coords.getLongitude();//double
}
catch (Exception e) {
e.printStackTrace();
}

代码运行结果如下图所示:

Cellid result3.PNG


源代码

File:CellID com.nokia.mid.location.LocationUtil.zip


相关链接

234 page views in the last 30 days.
×