another question,

If I use addJavascriptInterface(getCurrentPosition,
"getCurrentPostion") and make a call in javascript like this :
getCurrentposition( successCallback, errorCallback );

and successCallback and ErroCallback are implemented in the JS , how
it's works this?! I can use javascript function in that way?

On 8 mayo, 09:50, "[email protected]" <[email protected]> wrote:
> The main problem is to access to the public attributes methods of the
> instance object from javascript, because I try to implement the W3C
> standard.
> This standard explicit force the access to the data through public
> attributes ( no from public methods).
> The above class hierarchy that i shows you is not casual, the W3C
> constrained it, and if i want to be according with that standard i
> need to implement in this way.
> My question is if i can do it using webview interface
> (addJavascriptInterface), or i need to do something more to adapt it
> to provide support to this standard in android. Can anybody give me
> some ideas to implement this feature in android, any ideas are
> welcome.
> best regards.
>
> On May 7, 7:36 pm, "Mark Murphy" <[email protected]> wrote:
>
> > > 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to