开发者

How obtain geo location of Android phone in a servlet?

I installed on my Android phone a servlet container app with i-Jetty and created a servlet that exchanges GPS locations. I know that creating an Android application would be easier, but in the end I want to use it in any device, so a servlet is better.

The problem is that I开发者_Python百科 don't know how to make my get the GPS location of the Android phone in my servlet class. Does anyone have an idea?


I think without creating a native android app you won't have access to the phone's internal gps sensor. If creating an android app is out of the question you could still get a rough estimate of your coordinates via the ip address. Though this would have the drawback of either implementing your own ip database into the application (which is fairly large - available eg. from: http://www.maxmind.com/app/geolitecity ) or relying on a third party service.


as @Guido said i-jetty project site says that "webapps developed for i-jetty have access to the Android API So you have to add the imports that you want use from android and call the functions that you need. I only test get contacts but gps location should work as well.

ps: you can only test the servlet on android mobile otherwise you will have problems with the imports.


There is still a very little userbase as there is no detailed answer here I guess.

You can of course access the android internals from your webapp, otherwise i-jetty wouldn't make a lot of sense. Have a look at the hello world example which shows how to access the android context from within a webapp.

The one major drawback I think using i-jetty is, that you have to compile it to whatever permissions you need. For example, if you want to access bluetooth, you can't just have your webapp use it (even though you can make the call) but you have to include the permission to use bluetooth in the i-jetty apps AndroidManifest.

So if you still want to do this the i-jetty way, download the source, have a look at the hello world webapp, compile i-jetty with the proper permissions set in the manifest and copy some gps example from the web in to your webapp using the android context your webapp gets passed upon creation.

Hope this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜