[AC-2891] Android Webview fireEvent doesn't work if a custom module is included in the project
GitHub Issue
n/a
Type
Bug
Priority
n/a
Status
Closed
Resolution
Fixed
Resolution Date
2012-02-14T14:48:58.000+0000
Affected Version/s
n/a
Fix Version/s
n/a
Components
Appcelerator Modules, Titanium SDK & CLI
Labels
android, custom, fireevent, module, webview
Reporter
Mark Burggraf
Assignee
Josh Roesslein
Created
2012-02-11T11:29:09.000+0000
Updated
2016-03-08T07:47:51.000+0000
Description
In Android, a webview can can call Titanium.App.fireEvent just fine UNLESS you have a custom module in your project. Once you call a custom module with the require() syntax, all webview fireEvent calls fail. See the complete example below (you'll need to add your own custom module):
// if you uncomment the external module line below, webview can no longer call fireEvent!
//var SQLOBJ = require("com.dmarie.sql");
var win = Titanium.UI.createWindow({
backgroundColor : '#fff'
});
Titanium.App.addEventListener("testEvent",function(e){
Titanium.API.info("****testEvent fired...");
alert("it works:" + e.obj);
})
var webview = Titanium.UI.createWebView({
html : ""+
"
This only happens with our module (com.dmarie.sql) which uses a lot of native .c code and the NDK.
Also of note, is that if the require("com.dmarie.sql") is moved AFTER the win.open() call, the bug does not occur.
Third, after require("com.dmarie.sql") is called, all webview objects have the problem. Even if those webviews are in other windows, or declared in a separate commonJS module.
Mark Burggraf 2012-02-14
The problem was in the custom module.
Creating a new instance of AppModule caused the problem:
module = new AppModule()
Instead, we changed this reference to:
AppModule app = (AppModule)TiApplication.getInstance().getModuleByName("App");
This problem is now resolved.
Josh Roesslein 2012-02-14
Confirmed resolved by reporter and no further action required from our end.
This only happens with our module (com.dmarie.sql) which uses a lot of native .c code and the NDK. Also of note, is that if the require("com.dmarie.sql") is moved AFTER the win.open() call, the bug does not occur. Third, after require("com.dmarie.sql") is called, all webview objects have the problem. Even if those webviews are in other windows, or declared in a separate commonJS module.
The problem was in the custom module. Creating a new instance of AppModule caused the problem: module = new AppModule() Instead, we changed this reference to: AppModule app = (AppModule)TiApplication.getInstance().getModuleByName("App"); This problem is now resolved.
Confirmed resolved by reporter and no further action required from our end.