Issue
I am developing native application. My application have a WebView
. I want to log this WebView
's component's every action. Which button clicked, which image dragged. After that, I will log those things, I want to store in SQLite.
So, I googled and find WebAppInterface
which communicates Java & JavaScript. But this communication isn't enough. I can't send database from WebAppInterface
class.
I want to ask this question actually (minute 46:00
).
Is it possible? Or, another solution?
Regards,
Solution
You should add javascript interface to your webView like that:
webView.addJavascriptInterface(new JavascriptInterface(this), "AndroidFunction");
You should create interface class:
public class JavascriptInterface{
Context mContext;
JavascriptInterface(Context c) {
mContext = c;
}
public void save(String action){
// save to database
}
}
On the website you should call:
AndroidFunction.save("actionName");
Answered By - Arkadiusz 'flies' Rzadkowolski
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.