J2ME and Location-Based Services

services

J2ME and Location-Based Services
Print-friendly Version

Location-based services (LBS) provide users of mobile devices personalized services tailored to their current location. They open a new market for developers, cellular network operators, and service providers to develop and deploy value-added services: advising users of current traffic conditions, supplying routing information, helping them find nearby restaurants, and many more.

This article introduces you to the field of LBS and to the Location API for J2ME (JSR 179), a set of generic APIs that can be used for developing location-based services. In addition, the article offers guidelines for designing location-based services.

What Location-Based Services Do
Location-based services answer three questions: Where am I? What's around me? How do I get there? They determine the location of the user by using one of several technologies for determining position, then use the location and other information to provide personalized applications and services. As an example, consider a wireless 911 emergency service that determines the caller's location automatically. Such a service would be extremely useful, especially to users who are far from home and don't know local landmarks. Traffic advisories, navigation help including maps and directions, and roadside assistance are natural location-based services. Other services can combine present location with information about personal preferences to help users find food, lodging, and entertainment to fit their tastes and pocketbooks.

There are two basic approaches to implementing location-based services:

Process location data in a server and deliver results to the device.
Obtain location data for a device-based application that uses it directly.
This article focuses on device-based location services.

Determining the Device's Location
To discover the location of the device, LBS must use real-time positioning methods. Accuracy depends on the method used.

Locations can be expressed in spatial terms or as text descriptions. A spatial location can be expressed in the widely used latitude-longitude-altitude coordinate system. Latitude is expressed as 0-90 degrees north or south of the equator, and longitude as 0-180 degrees east or west of the prime meridian, which passes through Greenwich, England. Altitude is expressed in meters above sea level. A text description is usually expressed as a street address, including city, postal code, and so on.

Applications can call on any of several types of positioning methods.

Using the mobile phone network: The current cell ID can be used to identify the Base Transceiver Station (BTS) that the device is communicating with and the location of that BTS. Clearly, the accuracy of this method depends on the size of the cell, and can be quite inaccurate. A GSM cell may be anywhere from 2 to 20 kilometers in diameter. Other techniques used along with cell ID can achieve accuracy within 150 meters.
Using satellites: The Global Positioning System (GPS), controlled by the US Department of Defense, uses a constellation of 24 satellites orbiting the earth. GPS determines the device's position by calculating differences in the times signals from different satellites take to reach the receiver. GPS signals are encoded, so the mobile device must be equipped with a GPS receiver. GPS is potentially the most accurate method (between 4 and 40 meters if the GPS receiver has a clear view of the sky), but it has some drawbacks: The extra hardware can be costly, consumes battery while in use, and requires some warm-up after a cold start to get an initial fix on visible satellites. It also suffers from "canyon effects" in cities, where satellite visibility is intermittent.
Using short-range positioning beacons: In relatively small areas, such as a single building, a local area network can provide locations along with other services. For example, appropriately equipped devices can use Bluetooth for short-range positioning.
In addition, location methods can connect to a mobile position center that provides an interface to query for the position of the mobile subscriber. The API to the mobile position center is XML-based. While applications can be fully self-contained on the device, it's clear that a wider array of services is possible when a server-side application is part of the overall service.

Some applications don't need high accuracy, but others will be useless if the location isn't accurate enough. It's okay for the location of a tourist walking around town to be off by 30 meters, but other applications and services may demand higher accuracy.

The Location API for J2ME
The Location API for J2ME specification defines an optional package, javax.microedition.location, that enables developers to write wireless location-based applications and services for resource-limited devices like mobile phones, and can be implemented with any common location method. The compact and generic J2ME location APIs provide mobile applications with information about the device's present physical location and orientation (compass direction), and support the creation and use of databases of known landmarks, stored in the device.

JSR 179 requires the Connected Device Configuration (CDC) or version 1.1 of the Connected Limited Device Configuration (CLDC). CLDC 1.0 isn't adequate because it doesn't support floating-point numbers, which the API uses to represent coordinates and other measurements. The Location API doesn't depend on any particular profile -- it can be used with MIDP or the Personal Profile.

The hardware platform determines which location methods are supported. If it doesn't support at least one location provider, LBS won't be possible. Applications can request providers with particular characteristics, such as a minimum degree of accuracy. Some location methods may be free; others may entail service fees. The application should warn the user before any charges are incurred.

It is up to the application to determine the criteria for selecting the location method. Criteria fields include: accuracy, response time, need for altitude, and speed. Once the application obtains a LocationProvider instance that meets the criteria, it can use that object to obtain the location, in either of two ways:

Invoke a method synchronously to get a single location.
Register a listener and get periodic updates at application-defined intervals.
The Location class abstracts the location results. Its object contains coordinates, speed if available, textual address if available, and a time stamp that indicates when the location measurements were made.

Coordinates are represented by either of two classes:

A Coordinates object represents a point's latitude and longitude in degrees, and altitude in meters.
A QualifiedCoordinates object contains latitude, longitude, and altitude, and also an indication of their accuracy, represented as the radius of an area.
The following segment of code demonstrates how to obtain the present location of the device synchronously:

...

// Set criteria for selecting a location provider:
// accurate to 500 meters horizontally
Criteria cr= new Criteria();
cr.setHorizontalAccuracy(500);

// Get an instance of the provider
LocationProvider lp= LocationProvider.getInstance(cr);

// Request the location, setting a one-minute timeout
Location l = lp.getLocation(60);
Coordinates c = l.getQualifiedCoordinates();

if(c != null ) {
// Use coordinate information
double lat = c.getLatitude();
double lon = c.getLongitude();
}
...

Landmarks
A landmark is a location associated with a name and a description. Landmarks can be stored in a device-based database, where they can be shared among all J2ME applications. Landmarks can store frequently used locations: home, office, favorite restaurants, and so on. Each is represented by a Landmark instance, and the database by a LandmarkStore. You can create multiple named LandmarkStores to group locations into categories such as cinemas, museums, or customer sites.

If the device includes a compass, the application may be able to determine not only its location but its orientation, which is useful in navigational applications. The Orientation class represents the device's azimuth as an angle from due north, which the application can easily convert to a compass direction.

Security and Privacy
Many users consider location information to be highly sensitive, and are concerned about a number of privacy issues, including:

Target marketing: Mobile users' locations can be used to classify customers for focused marketing efforts.
Embarrassment: One customer's knowledge of another's location may lead to embarrassing situations.
Harassment: Location information can be used to harass or attack a user.
Service denial: A health insurance firm might deny a claim if it learned that a user visited a high-risk area.
Legal restrictions: Some countries regulate the use of personal data.
For these and other reasons, users must know when their location is given to an application.

Guidelines
Keep the following guidelines in mind when designing location-based services:

Handle unavailability of services gracefully. The user's location may not always be available, for any of several reasons.
The device is cut off from any of the location methods it supports, in a tunnel or on an airplane for example.
The user withholds permission to release the information.
No location provider that the device supports is available.
Depending on the method used, determining the location may take a long time. The delay may be so long that the end result isn't useful in, for example, a navigation application. Keep the user informed.
Location service fees, typical of network-assisted location methods, can add up quickly, so don't overuse fee-based services.
Be sensitive to privacy concerns.
Tell customers about the information being collected on them and how it will be used.
Offer customers the choice of what location information to disclose, and when appropriate an option not to participate.
Allow customers to review their permission profiles so that they know what they are permitting.
Protect location information so that it cannot be accessed by unauthorized persons.
You should also take full advantage of the MIDP 2.0 security framework, which restricts the application's access to location data to cases in which the user explicitly confirms permission.

Summary
Through the Location API for J2ME, you can use information about the user's position to build new kinds of applications and services for mobile devices such as cell phones and PDAs, and to enhance existing services. JSR 179 specifies a generic API for obtaining locations, and thus makes porting LBS applications to a wide range of devices much easier. The critical issue that LBS developers must address is the privacy of the customer. To ensure privacy, follow sound programming guidelines and use the security framework in MIDP 2.0.

时间: 2024-08-20 00:23:44

J2ME and Location-Based Services的相关文章

互联网巨头“狂赌”地图 百度成立LBS事业部

你最喜欢用谁家的地图(导航),百度.谷歌.高德,还是微软的必应地图?从数据来看,在移动互联网领域,目前还没有一家能够独大,这也直接引发了互联网大佬开始酝酿在地图领域的"狂赌". 周三,百度宣布分拆百度地图,成立LBS事业部.LBS(定位服务)的核心是"位置",而位置的背后代表的则是"用户.流量.购买力以及营销和交易机会".百度会利用自身的LBS平台与相关厂商.开发者搭建一个生活服务开放平台,基于LBS精准营销.无疑,地图将成为百度力挖的下一座广告

解析互联网时代下的位置服务

在当下的互联网时代,位置服务已经成为移动互联网的标准配置,是当前学术界和产业界共同关心的热点.在服务模式方面,"位置"不仅是位置服务的内容,更是位置服务构成的输入性关键因素.在技术发展方面,本文探讨了移动定位技术迈向基于位置的社会感知这一发展趋势.位置服务涉及到信息科学.网络科学和测绘科学交叉创新的新理论和新技术,是移动互联网时代的创意产业和兴趣产业. 1 起源与兴起 以位置服务为代表的地球空间信息及应用服务产业已经成为当前IT产业的重要组成部分,与国民经济.社会发展各方面紧密联系,深

行业跟踪画布和竞品分析画布

如果决定做一款产品,那么分析一下这个产品所处的行业及发展状况是非常有必要的.我们需要知道这个行业的具体情况,从而定位我们的产品,产品所处的行业在很大程度上决定了产品最终的发展状况. 做行业分析,我们要重点分析下面几个问题:行业是朝阳行业还是夕阳行业?市场是红海还是蓝海?这个行业经历了几次发展,有哪些重要的转折点?是否有技术变革的趋势?有哪些新趋势能够带来行业变化? 行业跟踪画布 行业分析的最终目的是对行业有充分的了解,并能够对未来的1-3年的大趋势进行合理预测.为了更加规范和系统的进行行业分析,

《HTML5游戏编程核心技术与实战》——第1章 游戏和HTML5初探1.1 网页游戏和HTML5

第1章 游戏和HTML5初探 从时间上来计算,游戏行业从诞生到现在还不到100年历史,跟其他传统的行业相比,它甚至就像襁褓中的婴儿一样小,但正是这婴儿,正逐渐挑战着众多的传统行业.现在,很多人都会在不同的时刻玩着不同的游戏,也许你正在虚拟的网络游戏中热血澎湃地战斗,也许你正在电子游戏竞技中展现你的人生价值,也许你在忙碌的工作后,玩着切水果游戏不停地发泄,总之,你会感受到,它正在悄然融入到我们的生活当中,正在成为你生活的一部分. 随着新一代Web开发标准--HTML5诞生,各大浏览器厂商和软件厂商

《位置大数据隐私管理》—— 1.2 概念与定义

1.2 概念与定义 1.2.1 位置表示与定位技术 位置通常由三元组(x, y, t)表示,其中(x, y)表示移动对象所在的经纬度或者在某个参考坐标系(如UTM坐标系)下的坐标值,t表示时刻.表1-1展示移动对象O1.O2.O3在t1.t2.t3时刻的位置.以O1为例,在t1时刻,O1的位置坐标是(1, 2):在t2时刻,O1的位置坐标是(3, 3)等. 一个用户在不同时刻的位置组成该用户的轨迹.轨迹是移动对象的位置信息按时间排序形成的序列.通常情况下,一条轨迹可表示为: 其中,id是轨迹标识

BAT三巨头中的百度是否又一次跑慢

当阿里巴巴频繁高调投资微博.高德弥补移动短板,腾讯手握移动互联网"站票"微信时,BAT三巨头中的百度是否又一次"跑慢"了? "现在百度的移动策略是'先开枪,再瞄准',看到大方向就去做,在执行中不断修正."近日,百度移动云事业部副总经理岳国锋接受<第一财经日报>记者采访时如是回应,"也许在外界看来我们慢了,但我们战略观察上并不慢,一些投资并购对象,甚至已经看到硅谷去了." 他告诉记者,在技术上,百度年初成立了深度学习

百度地图推API打造开放平台

日前,全球最大中文搜索引擎百度旗下产品--百度地图(ditu.baidu.com)正式对外宣布开放API(应用程序接口),通过JavaScript将百度地图嵌入到网页应用程序接口,使网站能创建功能全面的地图应用程序. 这意味着300万中文网站将有可能通过二次开发,为他们的用户提供更为准确详实.基于地理位置的生活信息服务.分析认为,依赖百度强势的品牌和技术资源支持,此次地图API开放将影响亿万网民的在线生活和信息获取方式,并带动本地化互联网应用浪潮的到来. 推动网络地图应用生态圈成熟 互联网的普及

Android GPS详解及示例代码_Android

LBS(Location Based Services)直译的话就是基于地理位置的服务,这里面至少有两层意思,第一要能轻易的获取当前的地理位置,譬如经纬度海拔等,另一个就是在当前位置的基础上提供增值服务,譬如找附近的加油站.餐馆.酒店等.这里面的第一步:获取用户当前位置,我们就可以用Android的GPS定位服务来得到.Android提供了基于网络的定位服务和基于卫星的定位服务两种.在设置->位置和安全设置里面的前三项就是,最后一个增强型GPS是为了辅助快速找卫星的.  那么我们现在就写一个简单

物联网时代商业模式将驱动商业策略的转变

物联网时代的商业模式转移将驱动商业策略的转变. 我们认为,面对未来趋势,科技公司应考量在现有的组织外设立独立运作的机制;同时建立创投思维,以管理产品组合(portfolio)的模式针对不同应用场景的服务进行统筹规划. 在物联网的世界,科技产品必须更加契合用户具体的个别生活场景,科技行业的商业模式因此将出现本质性的变化.我们认为,五个主要的模式转移将驱动物联网时期的商业策略: 一.从横向拉通(Horizontal)到重视垂直行业特性(Vertical) 首先是市场构成. 在智能手机时期,绝大多数的

物联网时代全面来临之前,你需要了解这三大商业模式

物联网时代的商业模式转移将驱动商业策略的转变. 我们认为,面对未来趋势,科技公司应考量在现有的组织外设立独立运作的机制:同时建立创投思维,以管理产品组合(portfolio)的模式针对不同应用场景的服务进行统筹规划. 在物联网的世界,科技产品必须更加契合用户具体的个别生活场景,科技行业的商业模式因此将出现本质性的变化.我们认为,五个主要的模式转移将驱动物联网时期的商业策略: 一.从横向拉通(Horizontal)到重视垂直行业特性(Vertical) 首先是市场构成. 在智能手机时期,绝大多数的