[TIMOB-26638] Android: Root Ti.Android.Activity "intent" property should be updated when "newintent" event is fired
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2019-01-04T21:18:40.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 8.0.0 |
Components | Android |
Labels | android, breaking-change, intent, intent-filter, singletask |
Reporter | Joshua Quick |
Assignee | Joshua Quick |
Created | 2018-12-08T05:53:09.000+0000 |
Updated | 2019-01-08T10:35:25.000+0000 |
Description
*Summary:*
Currently, the root
Ti.Android.Activity
object's "intent" property never changes when a "newintent" event gets fired. The activity's "intent" property returns the intent that originally launched/created the activity.
We can improve the usability of the app's "newintent" and intent-filter handling if the root activity's "intent" property was updated to the same intent provided by the "newintent" event.
Note that Ti.App.Android
provides a [launchIntent](https://docs.appcelerator.com/platform/latest/#!/api/Titanium.App.Android-property-launchIntent) property which already provides the intent used to launch/create the root activity. So, we're not losing anything by making this change.
Also, it's currently possible to miss the "newintent" event on app startup, before the "app.js" has a chance to set up a listener for it.
var rootActivity = Ti.Android.currentActivity;
rootActivity.addEventListener("newintent", function(e) {
// Ideally, the 2 intents logged below should be the same.
Ti.API.info("### event.intent: " + JSON.stringify(e.intent));
Ti.API.info("### rootActivity.intent: " + JSON.stringify(rootActivity.intent));
// The launch intent property must never change.
Ti.API.info("### launchIntent: " + JSON.stringify(Ti.App.Android.launchIntent));
});
PR (master): https://github.com/appcelerator/titanium_mobile/pull/10519
FR Passed. PR Merged.
*Closing ticket.* The improvement is present in SDK: {noformat} 8.0.0.v20190104153150 {noformat}