Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-10016] Android: match() method returns: Ljava.lang.Object;@40528e70

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionInvalid
Resolution Date2012-12-05T03:07:25.000+0000
Affected Version/sRelease 2.1.0, Release 3.0.0
Fix Version/s2012 Sprint 25, 2012 Sprint 25 Core
ComponentsAndroid
Labelsapi, insight, parity
ReporterEduardo Gomez
AssigneeAllen Yeung
Created2012-07-17T22:54:40.000+0000
Updated2017-03-29T15:54:18.000+0000

Description

Issue

Calling match() method returns a hash i.e. Ljava.lang.Object;@40528e70 that needs to be handled as an array in Android.

Tested on

iOS 5.1 simulator Android Razr 2.3.5

DDMS console

07-18 00:50:15.431: I/ALERT(31085): (KrollRuntimeThread) [93,93] [Ljava.lang.Object;@40528318
07-18 00:50:15.431: I/TiAPI(31085): http://www.appcelerator.com

Repro sequence

var win = Titanium.UI.createWindow({
	title: 'Main',
	exitOnClose: true,
	fullscreen: false,
	navBarHidden: false,
	backgroundColor: 'gray'
});

win.addEventListener('open', function() {
	
	var tweet = 'blah blah blah @YouTube. http://www.appcelerator.com blah blah - Spot 1';
	extractURL(tweet);
});

win.open();

function extractURL(tweet) {

	var urlRegex = /(http?:\/\/[^\s]+)/g;
	var URL = tweet.toString().match(urlRegex);

	if (URL !== null) {

		//URL found
		alert( URL );
		//alert( URL[0] );//Work Around
		Ti.API.info( URL );
		
		win.add(
			Ti.UI.createWebView({
				url: URL
			})
		);
		
	} else {

		alert('No URL found');

		return;
	}

}//extractURL

match Method

https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/match

Comments

  1. Allen Yeung 2012-12-05

    Match is actually returning an array, which is correct. Here, you as passing an array of Strings to both alert() and the url property for webview, which is causing this crash. In the docs, both of those properties should be strings, not arrays. This works in iOS as a result of some internal conversion they do. There are no plans to support arrays for the properties mentioned on the Android side.
  2. Lee Morris 2017-03-29

    Closing ticket as invalid, with reference to the above comments.

JSON Source