[TIMOB-3465] Android: XML Cannot call method parseString if only defined inside an event listener
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Trivial |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2011-07-27T09:22:59.000+0000 |
Affected Version/s | Release 1.6.2 |
Fix Version/s | Sprint 2011-30, Release 1.8.0 |
Components | Android |
Labels | reported-1.6.1, tooling, xml |
Reporter | Jon Alter |
Assignee | Natalie Huynh |
Created | 2011-04-15T03:45:31.000+0000 |
Updated | 2011-08-26T16:15:19.000+0000 |
Description
On Android, If parseString is only defined inside an event
listener then you will get an error.
Note
This only happens until you define it outside of the eventListener once. After that it will work fine in that application even if it is inside an event listener. In order to reproduce this error you MUST create a new application.
Step 1: Create a NEW application
Step 2: Paste the example below into app.js
Step 3: Run the app
Step 4: Click 'Find Foo'
Step 5: Notice Runtime Error (picture of error attached)
var xmlString = '<items><foo>FOO</foo><bar>BAR</bar></items>';
var window = Ti.UI.createWindow({
backgroundColor: 'green'
});
var button = Ti.UI.createButton({
title: 'Find Foo',
height: 60,
width: 100,
top: 40
});
button.addEventListener('click', function(e){
var xml = Titanium.XML.parseString(xmlString);
var element = xml.getElementsByTagName("foo");
Ti.API.info( element.item(0).text );
});
window.add(button);
window.open();
Tested on
TiSDK 1.6.1, Android SDK 2.1
Attachments
File | Date | Size |
---|---|---|
error.jpg | 2011-04-15T03:45:31.000+0000 | 81012 |
pull request ready https://github.com/appcelerator/titanium_mobile/pull/276
XML module was not being included in build because: a) It has an all upper case name, which means it was being treated as a constant rather than a module. b) No other module outside of Network had a dependency on it, and only Yahoo has a dependency on Network, so it was easy for XML to be avoided given (a) above.
Reviewed and tested.
Tested with 1.8.0.v20110819142548 on Motorola Xoom 3.2 Droid 1 2.2.2