仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1131|回复: 18
打印 上一主题 下一主题

[学习教程] JAVA网页编程之J2ME and Location-Based Services

[复制链接]
小妖女 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-1-18 11:35:43 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
C#跟java类似,但是在跨平台方面理论上可以跨平台,实际上应用不大,执行性能优于java,跟C++基本一致,但是启动速度还是慢.代码安全,但容易性能陷阱.servicesJ2MEandLocation-BasedServices
Print-friendlyVersion





Location-basedservices(LBS)provideusersofmobiledevicespersonalizedservicestailoredtotheircurrentlocation.Theyopenanewmarketfordevelopers,cellularnetworkoperators,andserviceproviderstodevelopanddeployvalue-addedservices:advisingusersofcurrenttrafficconditions,supplyingroutinginformation,helpingthemfindnearbyrestaurants,andmanymore.

ThisarticleintroducesyoutothefieldofLBSandtotheLocationAPIforJ2ME(JSR179),asetofgenericAPIsthatcanbeusedfordevelopinglocation-basedservices.Inaddition,thearticleoffersguidelinesfordesigninglocation-basedservices.

WhatLocation-BasedServicesDo
Location-basedservicesanswerthreequestions:WhereamI?Whatsaroundme?HowdoIgetthere?Theydeterminethelocationoftheuserbyusingoneofseveraltechnologiesfordeterminingposition,thenusethelocationandotherinformationtoprovidepersonalizedapplicationsandservices.Asanexample,considerawireless911emergencyservicethatdeterminesthecallerslocationautomatically.Suchaservicewouldbeextremelyuseful,especiallytouserswhoarefarfromhomeanddontknowlocallandmarks.Trafficadvisories,navigationhelpincludingmapsanddirections,androadsideassistancearenaturallocation-basedservices.Otherservicescancombinepresentlocationwithinformationaboutpersonalpreferencestohelpusersfindfood,lodging,andentertainmenttofittheirtastesandpocketbooks.

Therearetwobasicapproachestoimplementinglocation-basedservices:

Processlocationdatainaserveranddeliverresultstothedevice.
Obtainlocationdataforadevice-basedapplicationthatusesitdirectly.
Thisarticlefocusesondevice-basedlocationservices.

DeterminingtheDevicesLocation
Todiscoverthelocationofthedevice,LBSmustusereal-timepositioningmethods.Accuracydependsonthemethodused.

Locationscanbeexpressedinspatialtermsorastextdescriptions.Aspatiallocationcanbeexpressedinthewidelyusedlatitude-longitude-altitudecoordinatesystem.Latitudeisexpressedas0-90degreesnorthorsouthoftheequator,andlongitudeas0-180degreeseastorwestoftheprimemeridian,whichpassesthroughGreenwich,England.Altitudeisexpressedinmetersabovesealevel.Atextdescriptionisusuallyexpressedasastreetaddress,includingcity,postalcode,andsoon.

Applicationscancallonanyofseveraltypesofpositioningmethods.

Usingthemobilephonenetwork:ThecurrentcellIDcanbeusedtoidentifytheBaseTransceiverStation(BTS)thatthedeviceiscommunicatingwithandthelocationofthatBTS.Clearly,theaccuracyofthismethoddependsonthesizeofthecell,andcanbequiteinaccurate.AGSMcellmaybeanywherefrom2to20kilometersindiameter.OthertechniquesusedalongwithcellIDcanachieveaccuracywithin150meters.
Usingsatellites:TheGlobalPositioningSystem(GPS),controlledbytheUSDepartmentofDefense,usesaconstellationof24satellitesorbitingtheearth.GPSdeterminesthedevicespositionbycalculatingdifferencesinthetimessignalsfromdifferentsatellitestaketoreachthereceiver.GPSsignalsareencoded,sothemobiledevicemustbeequippedwithaGPSreceiver.GPSispotentiallythemostaccuratemethod(between4and40metersiftheGPSreceiverhasaclearviewofthesky),butithassomedrawbacks:Theextrahardwarecanbecostly,consumesbatterywhileinuse,andrequiressomewarm-upafteracoldstarttogetaninitialfixonvisiblesatellites.Italsosuffersfrom"canyoneffects"incities,wheresatellitevisibilityisintermittent.
Usingshort-rangepositioningbeacons:Inrelativelysmallareas,suchasasinglebuilding,alocalareanetworkcanprovidelocationsalongwithotherservices.Forexample,appropriatelyequippeddevicescanuseBluetoothforshort-rangepositioning.
Inaddition,locationmethodscanconnecttoamobilepositioncenterthatprovidesaninterfacetoqueryforthepositionofthemobilesubscriber.TheAPItothemobilepositioncenterisXML-based.Whileapplicationscanbefullyself-containedonthedevice,itsclearthatawiderarrayofservicesispossiblewhenaserver-sideapplicationispartoftheoverallservice.

Someapplicationsdontneedhighaccuracy,butotherswillbeuselessifthelocationisntaccurateenough.Itsokayforthelocationofatouristwalkingaroundtowntobeoffby30meters,butotherapplicationsandservicesmaydemandhigheraccuracy.

TheLocationAPIforJ2ME
TheLocationAPIforJ2MEspecificationdefinesanoptionalpackage,javax.microedition.location,thatenablesdeveloperstowritewirelesslocation-basedapplicationsandservicesforresource-limiteddeviceslikemobilephones,andcanbeimplementedwithanycommonlocationmethod.ThecompactandgenericJ2MElocationAPIsprovidemobileapplicationswithinformationaboutthedevicespresentphysicallocationandorientation(compassdirection),andsupportthecreationanduseofdatabasesofknownlandmarks,storedinthedevice.

JSR179requirestheConnectedDeviceConfiguration(CDC)orversion1.1oftheConnectedLimitedDeviceConfiguration(CLDC).CLDC1.0isntadequatebecauseitdoesntsupportfloating-pointnumbers,whichtheAPIusestorepresentcoordinatesandothermeasurements.TheLocationAPIdoesntdependonanyparticularprofile--itcanbeusedwithMIDPorthePersonalProfile.

Thehardwareplatformdetermineswhichlocationmethodsaresupported.Ifitdoesntsupportatleastonelocationprovider,LBSwontbepossible.Applicationscanrequestproviderswithparticularcharacteristics,suchasaminimumdegreeofaccuracy.Somelocationmethodsmaybefree;othersmayentailservicefees.Theapplicationshouldwarntheuserbeforeanychargesareincurred.

Itisuptotheapplicationtodeterminethecriteriaforselectingthelocationmethod.Criteriafieldsinclude:accuracy,responsetime,needforaltitude,andspeed.OncetheapplicationobtainsaLocationProviderinstancethatmeetsthecriteria,itcanusethatobjecttoobtainthelocation,ineitheroftwoways:

Invokeamethodsynchronouslytogetasinglelocation.
Registeralistenerandgetperiodicupdatesatapplication-definedintervals.
TheLocationclassabstractsthelocationresults.Itsobjectcontainscoordinates,speedifavailable,textualaddressifavailable,andatimestampthatindicateswhenthelocationmeasurementsweremade.

Coordinatesarerepresentedbyeitheroftwoclasses:

ACoordinatesobjectrepresentsapointslatitudeandlongitudeindegrees,andaltitudeinmeters.
AQualifiedCoordinatesobjectcontainslatitude,longitude,andaltitude,andalsoanindicationoftheiraccuracy,representedastheradiusofanarea.
Thefollowingsegmentofcodedemonstrateshowtoobtainthepresentlocationofthedevicesynchronously:

...

//Setcriteriaforselectingalocationprovider:
//accurateto500metershorizontally
Criteriacr=newCriteria();
cr.setHorizontalAccuracy(500);

//Getaninstanceoftheprovider
LocationProviderlp=LocationProvider.getInstance(cr);

//Requestthelocation,settingaone-minutetimeout
Locationl=lp.getLocation(60);
Coordinatesc=l.getQualifiedCoordinates();

if(c!=null){
//Usecoordinateinformation
doublelat=c.getLatitude();
doublelon=c.getLongitude();
}
...




Landmarks
Alandmarkisalocationassociatedwithanameandadescription.Landmarkscanbestoredinadevice-baseddatabase,wheretheycanbesharedamongallJ2MEapplications.Landmarkscanstorefrequentlyusedlocations:home,office,favoriterestaurants,andsoon.EachisrepresentedbyaLandmarkinstance,andthedatabasebyaLandmarkStore.YoucancreatemultiplenamedLandmarkStorestogrouplocationsintocategoriessuchascinemas,museums,orcustomersites.

Ifthedeviceincludesacompass,theapplicationmaybeabletodeterminenotonlyitslocationbutitsorientation,whichisusefulinnavigationalapplications.TheOrientationclassrepresentsthedevicesazimuthasananglefromduenorth,whichtheapplicationcaneasilyconverttoacompassdirection.

SecurityandPrivacy
Manyusersconsiderlocationinformationtobehighlysensitive,andareconcernedaboutanumberofprivacyissues,including:

Targetmarketing:Mobileuserslocationscanbeusedtoclassifycustomersforfocusedmarketingefforts.
Embarrassment:Onecustomersknowledgeofanotherslocationmayleadtoembarrassingsituations.
Harassment:Locationinformationcanbeusedtoharassorattackauser.
Servicedenial:Ahealthinsurancefirmmightdenyaclaimifitlearnedthatauservisitedahigh-riskarea.
Legalrestrictions:Somecountriesregulatetheuseofpersonaldata.
Fortheseandotherreasons,usersmustknowwhentheirlocationisgiventoanapplication.

Guidelines
Keepthefollowingguidelinesinmindwhendesigninglocation-basedservices:

Handleunavailabilityofservicesgracefully.Theuserslocationmaynotalwaysbeavailable,foranyofseveralreasons.
Thedeviceiscutofffromanyofthelocationmethodsitsupports,inatunneloronanairplaneforexample.
Theuserwithholdspermissiontoreleasetheinformation.
Nolocationproviderthatthedevicesupportsisavailable.
Dependingonthemethodused,determiningthelocationmaytakealongtime.Thedelaymaybesolongthattheendresultisntusefulin,forexample,anavigationapplication.Keeptheuserinformed.
Locationservicefees,typicalofnetwork-assistedlocationmethods,canaddupquickly,sodontoverusefee-basedservices.
Besensitivetoprivacyconcerns.
Tellcustomersabouttheinformationbeingcollectedonthemandhowitwillbeused.
Offercustomersthechoiceofwhatlocationinformationtodisclose,andwhenappropriateanoptionnottoparticipate.
Allowcustomerstoreviewtheirpermissionprofilessothattheyknowwhattheyarepermitting.
Protectlocationinformationsothatitcannotbeaccessedbyunauthorizedpersons.
YoushouldalsotakefulladvantageoftheMIDP2.0securityframework,whichrestrictstheapplicationsaccesstolocationdatatocasesinwhichtheuserexplicitlyconfirmspermission.

Summary
ThroughtheLocationAPIforJ2ME,youcanuseinformationabouttheuserspositiontobuildnewkindsofapplicationsandservicesformobiledevicessuchascellphonesandPDAs,andtoenhanceexistingservices.JSR179specifiesagenericAPIforobtaininglocations,andthusmakesportingLBSapplicationstoawiderangeofdevicesmucheasier.ThecriticalissuethatLBSdevelopersmustaddressistheprivacyofthecustomer.Toensureprivacy,followsoundprogrammingguidelinesandusethesecurityframeworkinMIDP2.0.


到时我们不用学struts,不用学spring,不用学Hibernate,只要能把jsf学会了,完全可以替代所有的框架,包括AJAX,都知道AJAX并不是新技术,虽说我没深入学习jsf但我认为jsf应该已经能通过其它技术替代AJAX,实现无缝刷新。
深爱那片海 该用户已被删除
沙发
发表于 2015-1-21 10:41:19 | 只看该作者
接着就是EJB了,EJB就是Enterprise JavaBean, 看名字好象它是Javabean,可是它和Javabean还是有区别的。它是一个体系结构,你可以搭建更安全、更稳定的企业应用。它的大量代码已由中间件(也就是我们常听到的 Weblogic,Websphere这些J2EE服务器)完成了,所以我们要做的程序代码量很少,大部分工作都在设计和配置中间件上。
飘灵儿 该用户已被删除
板凳
发表于 2015-1-28 05:40:07 | 只看该作者
一直感觉JAVA很大,很杂,找不到学习方向,前两天在网上找到了这篇文章,感觉不错,给没有方向的我指了一个方向,先不管对不对,做下来再说。
愤怒的大鸟 该用户已被删除
地板
发表于 2015-2-4 14:51:44 | 只看该作者
还好,SUN提供了Javabean可以把你的JSP中的 Java代码封装起来,便于调用也便于重用。
不帅 该用户已被删除
5#
发表于 2015-2-10 01:48:38 | 只看该作者
[url]http://www.jdon.com/[/url]去下载,或到同济技术论坛的服务器[url]ftp://nro.shtdu.edu.cn[/url]去下,安装上有什么问题,可以到论坛上去提问。
第二个灵魂 该用户已被删除
6#
发表于 2015-2-26 14:44:34 | 只看该作者
多重继承(以接口取代)等特性,增加了垃圾回收器功能用于回收不再被引用的对象所占据的内存空间,使得程序员不用再为内存管理而担忧。在 Java 1.5 版本中,Java 又引入了泛型编程(Generic Programming)、类型安全的枚举、不定长参数和自动装/拆箱等语言特性。
若天明 该用户已被删除
7#
发表于 2015-2-27 13:12:29 | 只看该作者
[url]http://www.jdon.com/[/url]去下载,或到同济技术论坛的服务器[url]ftp://nro.shtdu.edu.cn[/url]去下,安装上有什么问题,可以到论坛上去提问。
因胸联盟 该用户已被删除
8#
发表于 2015-3-9 05:46:13 | 只看该作者
自从Sun推出Java以来,就力图使之无所不包,所以Java发展到现在,按应用来分主要分为三大块:J2SE,J2ME和J2EE,这也就是Sun ONE(Open Net Environment)体系。J2SE就是Java2的标准版,主要用于桌面应用软件的编程;J2ME主要应用于嵌入是系统开发,如手机和PDA的编程;J2EE是Java2的企业版,主要用于分布式的网络程序的开发,如电子商务网站和ERP系统。
简单生活 该用户已被删除
9#
发表于 2015-3-15 05:07:32 | 只看该作者
[url]http://www.jdon.com/[/url]去下载,或到同济技术论坛的服务器[url]ftp://nro.shtdu.edu.cn[/url]去下,安装上有什么问题,可以到论坛上去提问。
冷月葬花魂 该用户已被删除
10#
发表于 2015-3-17 20:54:41 | 只看该作者
另外编写和运行Java程序需要JDK(包括JRE),在sun的官方网站上有下载,thinking in java第三版用的JDK版本是1.4,现在流行的版本1.5(sun称作J2SE 5.0,汗),不过听说Bruce的TIJ第四版国外已经出来了,是专门为J2SE 5.0而写的。
灵魂腐蚀 该用户已被删除
11#
发表于 2015-3-20 14:20:33 | 只看该作者
是一种由美国SUN计算机公司(Sun Microsystems, Inc.)所研究而成的语言
山那边是海 该用户已被删除
12#
发表于 2015-4-3 03:08:10 | 只看该作者
还好,SUN提供了Javabean可以把你的JSP中的 Java代码封装起来,便于调用也便于重用。
飘飘悠悠 该用户已被删除
13#
发表于 2015-4-13 20:16:34 | 只看该作者
当然你也可以参加一些开源项目,一方面可以提高自己,另一方面也是为中国软件事业做贡献嘛!开发者在互联网上用CVS合作开发,用QQ,MSN,E-mail讨论联系,天南海北的程序员分散在各地却同时开发同一个软件,是不是很有意思呢?
蒙在股里 该用户已被删除
14#
发表于 2015-4-14 13:08:26 | 只看该作者
是一种由美国SUN计算机公司(Sun Microsystems, Inc.)所研究而成的语言
海妖 该用户已被删除
15#
发表于 2015-4-16 08:09:21 | 只看该作者
如果要向java web方向发展也要吧看看《Java web从入门到精通》学完再到《Struts2.0入门到精通》这样你差不多就把代码给学完了。有兴趣可以看一些设计模块和框架的包等等。
柔情似水 该用户已被删除
16#
发表于 2015-5-1 14:02:23 | 只看该作者
你可以去承接一些项目做了,一开始可能有些困难,可是你有技术积累,又考虑周全,接下项目来可以迅速作完,相信大家以后都会来找你的,所以Money就哗啦啦的。。。。。。
小妖女 该用户已被删除
17#
 楼主| 发表于 2015-5-4 11:46:47 | 只看该作者
有时间再研究一下MVC结构(把Model-View-Control分离开的设计思想)
活着的死人 该用户已被删除
18#
发表于 2015-5-6 16:12:00 | 只看该作者
关于设计模式的资料,还是向大家推荐banq的网站 [url]http://www.jdon.com/[/url],他把GOF的23种模式以通俗易懂的方式诠释出来,纯Java描述,真是经典中的经典。
再见西城 该用户已被删除
19#
发表于 2015-5-11 02:51:47 | 只看该作者
象、泛型编程的特性,广泛应用于企业级Web应用开发和移动应用开发。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-12-23 02:20

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表