On 2010-02-09, at 1:22 PM, grimace wrote:
> Is there some document that can show how to add a custom command to
> gap code?
>
> --
> You received this message because you are subscribed to the Google
> Groups "phonegap" group.
> To post to this group, send email to phon...@googlegroups.com
> To unsubscribe from this group, send email to
> phonegap+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/phonegap?hl=en?hl=en
>
> For more info on PhoneGap or to download the code go to www.phonegap.com
function Myclass (){
}
Myclass.prototype.someThing = function(){
//leave these js functions empty. you will implement them in java code
}
PhoneGap.addConstructor(function() {
if (typeof navigator.accelerometer == "undefined")
navigator.myclass= new Myclass();
});
add it as contructor and go to the droidGap.java
//don't forget to define the types before you assign this
mything = new MyJavaClass(view, this);
appView.addJavascriptInterface(mything, "Myclass");
//now when you call something from javascript's Myclass, it will call
the MyJavaClass functions
But you have to define the functions in you javascript even they are
empty.