What I want to do is print out every URL that is loaded within a WebView in my Appcelerator project. Let’s call it a console window. I also want to log URLs requested by Flash plugins. Upon searching these forums, it appears that onLoadResource should work, but I’m not sure how to implement this Java code into my Appcelerator project. I assume I’ll need a custom module? The code I think I need would be something like this:
@Override
public void onLoadResource (WebView view, String url) {
// Somehow give my Titanium app access to the url...
}
Any pointers on how to implement this?
“onLoadResource” does look like what you want. And you are correct in assuming you will need to build a custom module (because onLoadResource is not exposed by Titanium Mobile).
Your quickest route forward would be to copy all of the existing Titanium Mobile web view related code in to a module you create, and then override the onLoadResource method, firing an event or logging the loaded URL.
Here’s a link to the relevant folder in GitHub: https://github.com/appcelerator/titanium_mobile/tree/master/android/modules/ui/src/java/ti/modules/titanium/ui/widget/webview