Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24527] Android: Intents using FLAG_ACTIVITY_NEW_DOCUMENT can cause issues with KrollRuntime

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2017-04-21T22:36:26.000+0000
Affected Version/sn/a
Fix Version/sRelease 6.0.4
ComponentsAndroid
Labelsn/a
ReporterGary Mathews
AssigneeGary Mathews
Created2017-03-23T14:35:48.000+0000
Updated2017-04-21T23:46:23.000+0000

Description

Some applications specify the FLAG_ACTIVITY_NEW_DOCUMENT flag when launching applications (Gmail). This can cause event listeners to be overridden and fired in the incorrect activity instance. *TEST CASE* *tiapp.xml*
<android ...>
    ...
   <manifest ...>
       ...
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="http" />
            <data android:scheme="https" />
            <data android:host="www.android.com" />
        </intent-filter>
        ...
    </manifest>
</android>
*app.js*
var win = Ti.UI.createWindow({
        layout: 'vertical'
    }),
    bar = Ti.UI.createView({
        layout: 'horizontal',
        width: Ti.UI.FILL,
        height: Ti.UI.SIZE
    })
    currentData = Ti.UI.createButton({
        title: 'CURRENT DATA',
        left: 0
    }),
    clear = Ti.UI.createButton({
        title: 'CLEAR',
        right: 0
    }),
    scrollView = Ti.UI.createScrollView({
        layout: 'vertical',
        height: Ti.UI.FILL,
        backgroundColor: 'white'
    });

// show current data
currentData.addEventListener('click', function (e) {
    alert(Ti.Android.currentActivity.getIntent().data);
});

// clear intent log
clear.addEventListener('click', function (e) {
    scrollView.removeAllChildren();
});

// launch intent
scrollView.add(Ti.UI.createLabel({
    top: 10,
    color: 'black',
    text: 'LAUNCH INTENT ' + JSON.stringify(Ti.Android.currentActivity.getIntent()) + ' WITH DATA: ' + Ti.Android.currentActivity.getIntent().data
}));

bar.add(currentData);
bar.add(clear);
win.add(bar);
win.add(scrollView);
win.open();
1. Launch app via a link in Gmail: www.android.com/0 2. Press 'CURRENT DATA', should display www.android.com/0 3. Open recent apps menu and resume Gmail 4. Launch app via link in Gmail: www.android.com/1 5. Press 'CURRENT DATA', should display www.android.com/1 6. Open recent apps menu and resume Gmail 7. Launch app via a link in Gmail: www.android.com/0 8. Press 'CURRENT DATA', should display www.android.com/0 but does not

Comments

  1. Gary Mathews 2017-03-24

    master: https://github.com/appcelerator/titanium_mobile/pull/8908
  2. Gary Mathews 2017-03-28

    6_0_X: https://github.com/appcelerator/titanium_mobile/pull/8910
  3. Lokesh Choudhary 2017-04-21

    FR Done. Merged 6.0.4 PR waiting for build from CI to close.
  4. Lokesh Choudhary 2017-04-21

    Verified the fix in 6.0.4.v20170421153428. Closing.

JSON Source