> I'm developing a Geolocation tool following the geolocation standard
> in W3C, And I have this code:
> 3 files .java as follow:
>
> //NaviatorGeolocation.java
> //here all the imports
> public class NavigatorGeolocation extends Activity {
>
> Position position = new Position();
> //Coordinates co = new Coordinates();
> /** Called when the activity is first created. */
> @Override
> public void onCreate(Bundle savedInstanceState) {
> super.onCreate(savedInstanceState);
> setContentView(R.layout.main);
>
> WebView wv = new WebView(this);
> wv.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
> wv.getSettings().setJavaScriptEnabled(true);
>
> wv.addJavascriptInterface(position, "position");
>
> setContentView(wv);
> wv.loadUrl("http://test.libregeosocial.libresoft.es/gwt/
> nada.html");
> }
> }
>
> //Postion.java
> public class Position {
> public long timestamp;
> public Coordinates coords;
>
> public Position(){
> this.timestamp = 2929;
> coords = new Coordinates();
> }
>
> }
>
> //Coordinates.java
> public class Coordinates {
>
> public double latitude;
> public double longitude;
> public double altitude;
> public double accuracy;
> public double altitudeAccuracy;
> public double heading;
> public double speed;
>
> public Coordinates(){
> this.latitude = 9.9292;
> this.longitude = 444.21;
> this.altitude = 0.0;
> this.accuracy = 0.0;
> this.altitudeAccuracy = 0.0;
> this.heading = 0.0;
> this.speed = 0.0;
> }
> }
>
> My "nata.html" is as follow:
>
> <html>
> <head><title>JS calls Android Method</title></head>
> <body>
> <h1>JS on Android</h1>
> <script type="text/javascript">
> document.write("making tests--");
> document.write("recibido: " + position.coords.latitude);
> <--------- not work!!
> document.write("end");
> </script>
> </body>
> </html>
>
> I don't now why but the position.coords.latitude, not work, but if I
> try "position.timestamp" it works, returning 2929.
position.timestamp is a primitive value (long). position.coords is an object.
> I'm really thinking about that the Android , right now, CAN'T make use
> of the standard of geolocation...
Change your API. Either move your Coordinates data members (double) into
the Position object, or put methods on the Position object to access the
Coordinates data members. Or, create a native user interface (instead of
WebView) and use whatever internal API you want.
--
Mark Murphy (a Commons Guy)
http://commonsware.com
_The Busy Coder's Guide to Android Development_ Version 2.0 Available!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---