Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24497] Android: Resuming app from intent does not provide EXTRA

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2017-04-21T22:34:42.000+0000
Affected Version/sRelease 6.0.2
Fix Version/sRelease 6.0.4
ComponentsAndroid
Labelsqe-6.0.3
ReporterGary Mathews
AssigneeGary Mathews
Created2017-03-17T15:12:30.000+0000
Updated2017-04-21T23:51:21.000+0000

Description

1. Press "CREATE SHORTCUT" 2. Kill the app 3. Start the app via shortcut - observe correct behaviour (WITH EXTRA: TEST) 4. Move app into background 5. Resume the app using shortcut - observe invalid behaviour WITH EXTRA : null
var win = Ti.UI.createWindow({
        layout: 'vertical'
    }),
    bar = Ti.UI.createView({
        layout: 'horizontal',
        width: Ti.UI.FILL,
        height: Ti.UI.SIZE
    })
    createShortcut = Ti.UI.createButton({
        title: 'CREATE SHORTCUT',
        left: 0
    }),
    clear = Ti.UI.createButton({
        title: 'CLEAR',
        right: 0
    }),
    scrollView = Ti.UI.createScrollView({
        layout: 'vertical',
        height: Ti.UI.FILL,
        backgroundColor: 'white'
    });
 
// create homescreen shortcut
createShortcut.addEventListener('click', function (e) {
    var currentIntent = Ti.Android.currentActivity.getIntent(),
        shortcutIntent = Ti.Android.createIntent({
            action: "com.android.launcher.action.INSTALL_SHORTCUT",
        });
 
    currentIntent.setAction(Ti.Android.ACTION_MAIN);
    currentIntent.putExtra("shortcut", "TEST");
    currentIntent.addCategory(Ti.Android.CATEGORY_HOME);
 
    shortcutIntent.putExtra(Ti.Android.EXTRA_SHORTCUT_NAME, "SHORTCUT");
    shortcutIntent.putExtra(Ti.Android.EXTRA_SHORTCUT_INTENT, currentIntent);
 
    Ti.Android.currentActivity.sendBroadcast(shortcutIntent);
});
 
// clear intent log
clear.addEventListener('click', function (e) {
    scrollView.removeAllChildren();
});
 
// intent listener
Ti.Android.currentActivity.addEventListener('newintent', function (e) {
    scrollView.add(Ti.UI.createLabel({
        top: 10,
        color: 'black',
        text: 'INTENT ' + JSON.stringify(e.intent) + ' WITH EXTRA: ' + e.intent.getStringExtra('shortcut')
    }));
});
 
// launch intent
scrollView.add(Ti.UI.createLabel({
    top: 10,
    color: 'black',
    text: 'LAUNCH INTENT ' + JSON.stringify(Ti.Android.currentActivity.getIntent()) + ' WITH EXTRA: ' + Ti.Android.currentActivity.getIntent().getStringExtra('shortcut')
}));
 
bar.add(createShortcut);
bar.add(clear);
win.add(bar);
win.add(scrollView);
win.open();

Comments

  1. Gary Mathews 2017-03-20

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

    6_0_X: https://github.com/appcelerator/titanium_mobile/pull/8901
  3. Josh Longton 2017-03-22

    {noformat} Mac OS Version : 10.12.3 Appc CLI : 6.1.0 Appc NPM : 4.2.9-1 Node : v4.6.0 Device: Nexus 5x(6.0.1) Pixel XL(7.1.2) Emulator: (6.0), (4.4.2) {noformat} Using above env passed FR. After merge, the changes are present in SDK 6.0.3.v20170322110142. *Closing*
  4. Eric Merriman 2017-03-22

    Since this PR and the related ticket are inter-related, will reopen this and move to SDK 6.0.4 since we are unable to merge the other PR.
  5. Gary Mathews 2017-03-28

    6_0_X: https://github.com/appcelerator/titanium_mobile/pull/8910
  6. Nikita Radaev 2017-04-21

    Tested with 6.0.4.v20170420100617 -> doesnt work Tested with 6.1.0.v20170420092509 -> works fine Has this been added into latest 6.0.4 build?
  7. Lokesh Choudhary 2017-04-21

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

    Verified the fix in 6.0.4.v20170421153428. Closing.

JSON Source