I am migrating a web application into an android version.
Can anyone help with this ?
WebView contains a method called
Using this method, the object
JSONObject class in Java has a constructor that accepts a String containing JSON data. So, you can pass the stringified result directly back to Java and create the object that way. For example:
mObjectsFromJS map. You’ll of course want to add additional helper methods to the JSInterface class to allow for managing the objects better.
I haven’t compiled or tested any of these methods, so you may have to tweak them a bit for proper operation. But hopefully this gives you the idea.
This is giving remote code ability to trigger native code on your device. If you do not have complete control over the pages/scripts being loaded into the
WebView, you should ensure that the behavior exposed by
obj doesn’t allow any exploits.