Project: titanium
Issue TIMOB-7249: Android: Intent - getData(), getAction(), and getType() do not work
h2. Problem When deciding how an app should handle an incoming Android Intent, knowing the type, action, and data values that were sent with the Intent are critical. If your app only handles one very specific Intent, this is OK, but if you have an app that handles images, URIs, video,, etc... you need to know these values. Right now when an Intent is received via Intent Filter in Titanium, the following lists the values/errors you will get for the data, type, and action functions and properties of an Intent: * {{getData()}} always equals {{null}} * {{getType()}} and {{getAction()}} always throw this exception, despite the fact that logic and documentation dictates that these functions do not require arguments: {code}Uncaught Error: Requires property name as first argument{code} * The {{data}} property always returns {{null}} * The {{action}} and {{type}} properties always return {{undefined}} h2. Proposed Solution The above listed functions and properties need to return the appropriate values for {{data}}, {{type}}, and {{action}} so that developers will know what to do with the Android Intent that they are receiving. Like I said, if you are handling only one type of data as dictated by your Intent Filter, you are OK. But if you plan to handle images, video, etc... and you need to read them from Ti.Android.EXTRA_STREAM, you have no way of knowing which type of Intent you are receiving. Also, I believe the implementation of {{getAction()}} and {{getType()}} need to change so that they do not require a parameter. h2. Test Case {code:javascript} var win = Ti.UI.createWindow({ backgroundColor: '#fff', fullscreen: false, exitOnClose: true }); win.addEventListener('open', function(e) { var intent = Ti.Android.currentActivity.getIntent(); var iname = Ti.Android.EXTRA_STREAM; if (intent && intent.hasExtra(iname)) {	Ti.API.info(intent.getAction());	Ti.API.info(intent.getData());	Ti.API.info(intent.getType()); } else { Ti.API.info('No extra named "' + iname + '" found in Intent'); } }); win.open(); {code} It will also be necessary to add an intent filter to a custom AndroidManifest.xml to get this test case to receive intents. The only below needs to go in the main activity and will receive all image share intents. You can easily trigger an image share intent by long clicking on an image in the android gallery then select 'share' from the intent list. Then just select your test case app from the list. {code:xml} {code}
Story points: 1