Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-26638] Android: Root Ti.Android.Activity "intent" property should be updated when "newintent" event is fired

GitHub Issuen/a
TypeImprovement
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2019-01-04T21:18:40.000+0000
Affected Version/sn/a
Fix Version/sRelease 8.0.0
ComponentsAndroid
Labelsandroid, breaking-change, intent, intent-filter, singletask
ReporterJoshua Quick
AssigneeJoshua Quick
Created2018-12-08T05:53:09.000+0000
Updated2019-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));
});

Comments

  1. Joshua Quick 2018-12-12

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/10519
  2. Lokesh Choudhary 2019-01-04

    FR Passed. PR Merged.
  3. Josh Longton 2019-01-08

    *Closing ticket.* The improvement is present in SDK: {noformat} 8.0.0.v20190104153150 {noformat}

JSON Source