I believe that it’s possible to call Java methods from (PhoneGap) Javascript.
Anyone knows how to do that?? (I know how to do it by changing the source code of PhoneGap, but I’d avoid that)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I finally made it work.
Create a class with methods you want to use:
In your main activity add a Javascript interface for this class:
In Javascript call window.MyCls methods:
Note:
As mentioned in the comment, for Android version 4.2 and above, add
@JavascriptInterfaceto the method which you want to access from your HTML page. Reference.