Android - simple user input form web-view to back-end java with jQuery Mobile

前端 未结 1 1860
渐次进展
渐次进展 2021-01-03 04:17

I am currently designing a native android application. I am planning to use jQuery Mobile web view as my interface and do all the calculations with java back-end. (still dec

1条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-03 05:02

    OK, here's an example of interacting with the javascript interface...

    Setting the javascript interface in your Activity...

    JavascriptInterface javasriptInterface = new JavascriptInterface(this);
    webview.addJavascriptInterface(javasriptInterface, "Android");
    

    The inner JavascriptInterface class in your Android Activity...

    public class JavascriptInterface {
        Context mContext;
    
        JavascriptInterface(Context c) {
            mContext = c;
        }
    
        public boolean doSomething(String name, String address) {
            ...
            return true;
        }
    }
    

    EDIT: Your form will have various input fields. Example...

    0 讨论(0)
提交回复
热议问题