Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-20459] Android newintent event not fired

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2017-03-15T17:39:38.000+0000
Affected Version/sRelease 5.2.0
Fix Version/sRelease 6.0.2
ComponentsAndroid
Labelsn/a
ReporterFokke Zandbergen
AssigneeGary Mathews
Created2016-02-25T09:26:01.000+0000
Updated2017-03-17T15:13:06.000+0000

Description

With TIMOB-19679 users can now create additional launcher shortcuts. If the app is already open in the background, you should be able to listen to the newintent to be notified. However, it seems that this even does not work. This not only makes this new addition less useful, it might hurts other use cases where a running app needs to know if it was brought to the foreground with a specific intent, like when using URL schemes. The following sample demonstrates:

Run the app

Press the button to create a launcher shortcut

Force quit the app

Use the shortcut (named _Gallery_) to open the app

Confirm it logs _LAUNCH INTENT .. WITH EXTRA: gallery_ as expected (/)

Move the app to the background

Use the shortcut again

Confirm it does *not* log _NEW INTENT .. WITH EXTRA: gallery_ as expected (x)

*tiapp.xml*
	<android xmlns:android="http://schemas.android.com/apk/res/android">
		<manifest>
			<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
		</manifest>
	</android>
*app.js*
var win = Ti.UI.createWindow({
  layout: 'vertical'
});

var btn = Ti.UI.createButton({
  title: 'Create Shortcut'
});

btn.addEventListener('click', function(e) {
  var currentIntent = Ti.Android.currentActivity.getIntent();
  currentIntent.setAction(Ti.Android.ACTION_MAIN);

  // Add custom metadata to read when your App is launched from the shortcut.
  currentIntent.putExtra("shortcut", "gallery");

  // Create an Intent
  var shortcutIntent = Ti.Android.createIntent({
    action: "com.android.launcher.action.INSTALL_SHORTCUT",
  });

  // Title that will appear with the shortcut
  shortcutIntent.putExtra(Ti.Android.EXTRA_SHORTCUT_NAME, "Gallery");

  shortcutIntent.putExtra(Ti.Android.EXTRA_SHORTCUT_INTENT, currentIntent);
  shortcutIntent.putExtra("duplicate", false);

  // Set the icon for the shortcut
  var iconImage = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, "appicon.png").read();
  shortcutIntent.putExtra(Ti.Android.EXTRA_SHORTCUT_ICON, iconImage);

  // Adds the shortcut to the home screen.
  Ti.Android.currentActivity.sendBroadcast(shortcutIntent);
});

win.add(btn);

win.add(Ti.UI.createLabel({
  top: 10,
  text: 'LAUNCH INTENT ' + JSON.stringify(Ti.Android.currentActivity.getIntent()) + ' WITH EXTRA: ' + Ti.Android.currentActivity.getIntent().getStringExtra('shortcut')
}));

Ti.Android.currentActivity.addEventListener('newintent', function(e) {

  win.add(Ti.UI.createLabel({
    top: 10,
    text: 'NEW INTENT ' + JSON.stringify(e.intent) + ' WITH EXTRA: ' + e.intent.getStringExtra('shortcut')
  }));

});

win.open();

Attachments

FileDateSize
testcase.gif2017-01-09T22:05:31.000+00001509765

Comments

  1. Fokke Zandbergen 2016-02-25

    /cc [~msamah] [~jasonkneen] [~CollinPrice]
  2. Ashraf Abu 2016-02-26

    [~fokkezb] The sample app.js is how you'll except it to work? Just want to check with you.
  3. Fokke Zandbergen 2016-02-26

    [~msamah], sorry forgot the steps. Added them now.
  4. Ashraf Abu 2016-02-26

    Thank you!
  5. Ashraf Abu 2016-02-29

    [~fokkezb] Do you have a sample app.js of when newintent will fire on android in a normal situation? I'm looking at android docs http://developer.android.com/guide/components/tasks-and-back-stack.html and it seems that onNewIntent is fired when the flags FLAG_ACTIVITY_SINGLE_TOP or FLAG_ACTIVITY_NEW_TASK is used to create an activity. If the activity does not have those flags, it should be expected to not fire newintent.
  6. Fokke Zandbergen 2016-02-29

    Well, I added that flag here: https://github.com/appcelerator-developer-relations/appc-sample-ti520/blob/master/app/controllers/android/launcher.js#L28 Via:
       intentForShortcut.addFlags(Ti.Android.FLAG_ACTIVITY_SINGLE_TOP);
       
    But then still it does not fire the event. In the end the question is... how *do* we pick up on the app being "resumed" by an intent?
  7. Ashraf Abu 2016-03-01

    I took a dive into this more and checked out how onNewIntent is being called on Android natively. android:launchMode="singleTask" in the manifest will allow onNewIntent to be called. When I edited the tiapp.xml manifest as described by TIMOB-15253 to get singleTask working, OnNewIntent is indeed called BUT with that, it comes with the bug originally mentioned in TIMOB-15253 where you get a blank activity. It seems that newIntent has not really working well since singleTask is not working correctly.
  8. Fokke Zandbergen 2016-03-01

    [~msamah] thanks for diving in. I think we should look at this in the broader context of a (user) story instead of from a bug POV like this ticket and TIMOB-15253. In the end, what the user wants is for the app (either running or not) to be able to respond to an incoming intent of any sort, including being opened via an URL scheme. We also probably need to revise Ti.Android.currentActivity as since we now have "heavy-weight" windows that is probably just as useless as Ti.UI.currentWindow after getting rid of the url property and switching to CommonJS modules.
  9. Ashraf Abu 2016-03-01

    {quote}In the end, what the user wants is for the app (either running or not) to be able to respond to an incoming intent of any sort, including being opened via an URL scheme.{quote} If a method/pattern/coding way comes to mind on how else this can be achieved (incoming intent), do let me know. I understand that looking it from a story point of view is more important sometimes. I'll try to also see if this is possible with other ways or if we can do it another way.
  10. Fokke Zandbergen 2016-03-01

    I created TIMOB-20490 to talk about this from the user POV.
  11. Ashraf Abu 2016-03-02

    Super detailed ticket. I like it. (y)
  12. Scott Wilcox 2016-04-07

    I spoke to @fokkez about this via Twitter and tested going back a few SDK's as I was having issues firing a share intent. In 5.2.0, I could repeatedly fire new intents, however this appears to have broke in 5.2.1 and 5.2.2.
  13. Ashraf Abu 2016-04-07

    [~ssx] Could you share the sample code that you are using for this?
  14. Scott Wilcox 2016-04-07

    Sure, very simply: {noformat} // file is a Ti.Filesystem.File ref var intent = Ti.Android.createIntent({ action: Ti.Android.ACTION_SEND }); intent.putExtraUri(Ti.Android.EXTRA_STREAM, file.nativePath); var share = Ti.Android.createIntentChooser(intent, 'Send File'); Ti.Android.currentActivity.startActivity(share); {noformat} This would fire fine after install, as soon as the app is closed it wouldn't fire again past that point, adding in some debug, I did notice that newintent came back empty if that's of any help.
  15. Ajith Rohini 2016-06-06

    [~mrahman] Can you/one of our team members please look into this and update ?
  16. David Fox 2016-06-23

    Does anyone have any workaround for this, whether it be on the Titanium side or through Java in a module that's creating an intent? If I'm understanding the issue correctly, this literally makes it impossible to properly open an app that's running in the background with a notification that has a payload. It seems crazy that no one is doing that which makes me think maybe there is a workaround. Any ideas are appreciated because it seems like the fix for this is not coming any time soon and this is critical functionality IMO.
  17. Collin Price 2016-06-23

    My team has tried all manner of workarounds with no success. Apparently Appcelerator only cares about Windows support now.
  18. David Fox 2016-06-23

    Very, very sad to hear. A bug that renders a feature as important as notification support nearly useless should be top priority. I've been trying a lot of workarounds too with no luck :/
  19. Collin Price 2016-06-23

    I agree. This bug makes shortcuts, notifications, and url launching impossible. The support team has said they should have a fix by September... :(
  20. David Fox 2016-06-23

    Thanks for the info. That's a really long time for something this serious. Not good.
  21. Ashraf Abu 2016-06-24

    [~dfoxinator] Just want to understand, is it the newintent event not firing that is of your concern?
  22. David Fox 2016-06-24

    @msamah yes, the newintent not firing makes it impossible to actually detect when an Android app that is in the background is opened from a push notification. Because of this, various GCM plugins are using a hacky/unreliable/broken method of looking at the "last notification to arrive" when the app comes into focus which is the complete wrong way to do it and results in broken behavior.
  23. David Fox 2016-06-24

    And just to clarify, that's because the notification launcher intent can't actually pass data into the app. You can send the data in the extra field, but there's no way to actually get that info in Titanium because the new intent listener doesn't work.
  24. Collin Price 2016-07-06

    Is this bug ever going to get fixed? I keep seeing the scheduled release get bumped. 5.2.1 > 6.0.0 > 6.1.0
  25. Be Rushton 2016-07-06

    Yeah come on guys this is critical functionality.
  26. David Fox 2016-07-06

    I agree with the above comments. Unfortunately, because of this bug/issue, I've had to plan to move my app off of Appcelerator entirely.
  27. Neeraj Mishra 2016-07-19

    [~cng], Could you please have a look at the response customer provided in above comments i have added? Thanks Neeraj
  28. David Fox 2016-08-22

    Any update on this?
  29. Abdiel Aviles 2016-09-01

    [~dfoxinator] Have you tried setting android:launchMode="singleTask"? I was able to implement URL Schemes by setting this and by following the workaround suggested in TIMOB-15253. The newIntent event is fired when the app is in singleTask mode.
  30. Ashraf Abu 2016-09-01

    [~abdielou] Could you elaborate more on what you did?
  31. David Fox 2016-09-01

    Thanks for the suggestion. I was never able to get singleTask mode to work properly. I just got the black screen every time after I tried to open the app again, like some commenters on that ticket described.
  32. Abdiel Aviles 2016-09-01

    In order to fire the newIntent event I added the android:launchMode="singleTask" property to the activity on *tiapp.xml*. Then on alloy.js I added the newIntent event handler:
        Ti.Android.currentActivity.addEventListener("newIntent", function(e){
            // Grab the intent data and do something with it
            var theIntentData = e.intent.data;
            // Re-create index as suggested at TIMOB-15253
            Alloy.createController('index');
        });
        
  33. Jonas Funk Johannessen 2016-09-01

  34. David Fox 2016-09-01

    Is there any way to implement a similar workaround if you're not using Alloy?
  35. Ashraf Abu 2016-09-06

  36. David Fox 2016-09-07

    Ashraf - thanks for the heads up. That looks very promising. I've never built the mobile SDK from the source, so I'll have to figure out how to do that and then I will test it. Is it possible it will be available soon in a CI build on builds.appcelerator.com? Thanks.
  37. Ashraf Abu 2016-09-07

    It's currently on a branch that's in my forked repo. Thus not on CI (yet). For now, best way to test it is to build it from source. Let me know if you need more info on building from source. The guides should be available in the docs/wiki. There's also some changes in compiling for TiSDK 6+, refer to [https://github.com/appcelerator/titanium_mobile/blob/5a4a616857ed390f5aabd4e89dad794f6a6b6a8c/README.md#building-locally] for more info.
  38. David Fox 2016-09-11

    Hi Ashraf, Thanks for the info. I just tried to build the SDK, and I keep getting this error on the "node scons.js build" step of the process: { Error: ENOENT: no such file or directory, lstat '/Users/DFox/Downloads/titanium_mobile-TIMOB-20490a/dist/android/titanium.jar' at Error (native) errno: -2, code: 'ENOENT', syscall: 'lstat', path: '/Users/DFox/Downloads/titanium_mobile-TIMOB-20490a/dist/android/titanium.jar' } Any help is appreciated.
  39. David Fox 2016-09-11

    I finally got it compiled and installed. I will test it in the next day or too and report back.
  40. Ashraf Abu 2016-09-13

    [~dfoxinator] Glad you are able to compile it correctly.
  41. Gary Mathews 2016-09-26

    master: https://github.com/appcelerator/titanium_mobile/pull/8433
  42. Chee Kiat Ng 2016-10-03

    [~gmathews] please backport this.
  43. Lokesh Choudhary 2016-10-05

    Verified the fix. newintent event is fired successfully. Closing. Environment: Appc Studio : 4.8.0.201609292239 Ti SDK : 6.0.0.v20161005072811, 6.1.0.v20161005041716 Ti CLI : 5.0.10 Alloy : 1.9.2 MAC El Capitan : 10.11.6 Appc NPM : 4.2.8-7 Appc CLI : 6.0.0-56 Node: 4.4.4 Nexus 6 - Android 6.0.1
  44. Nikita Radaev 2016-10-06

    I've retested using sample code and came to a conclusion that this fix is incomplete. Here are my test scenarios: Scenario 1 ------------------------------ - Launch app normally. - Observe that LAUNCH INTENT and NEW INTENT were thrown WITH EXTRA : "null" - Create shortcut - Pause an app - Resume from shortcut - Observe that WITH EXTRA value is still "null" for both LAUNCH INTENT and NEW INTENT Scenario 2 ------------------------------ - Launch app normally - Create shortcut - Kill the app - Re-open the app using shortcut - Observe that LAUNCH INTENT and NEW INTENT were thrown WITH EXTRA : "gallery" - Pause an app - Resume an app from app icon (not shortcut) - Observe that WITH EXTRA value is still "gallery" for both LAUNCH INTENT and NEW INTENT Therefore, it is currently not possible to distinguish whether an app has been resumed from shortcut or not. Tested with: Ti SDK: 6.1.0.v20161003212029 Ti.CLI: 5.0.9 Device: Samsuns S6 - Android 6.0.1
  45. Ajith Rohini 2016-10-06

    [~gmathews], Please see the last comment from the client. As per them, this is still an issue. Can you please take a look ?
  46. Gary Mathews 2016-10-11

    [~nradaev] [~arohini] Try setting this flag under setAction
        currentIntent.setFlags(Ti.Android.FLAG_UPDATE_CURRENT);
        
  47. Nikita Radaev 2016-10-11

    Gary, I've run sample code using: currentIntent.setFlags(Ti.Android.FLAG_UPDATE_CURRENT); It does not work how we expect. Extra instances of the app are being created intead of resuming app with new intent. I’ve compiled a small Android app example that shows exact functionality we require. Note when the app is started/resumed from shortcut resulting text is “On Create/New Intent Started from shortcut”. Similarly when app is started/resumed from app icon resulting text is “On Create/New Intent null”. I've emailed a copy of the sample app to Ajith.
  48. Ricardo Ramirez 2016-10-19

    Hi guys ! Any update here ?
  49. Gary Mathews 2017-01-09

    master: https://github.com/appcelerator/titanium_mobile/pull/8733
  50. Eric Merriman 2017-01-20

    Reopening for back port
  51. Andy Waldman 2017-01-20

    Tested 20th january 2017: After creating a new classic app with environment: MacOS:10.12.1 XCODE: 8.2.1 GM (golden master) APPC CLI Core: 6.1.0 APPC CLI NPM: 4.2.8 SDK: 6.1.0.v20170118152304 Studio build: 4.8.1.201612050850 NPM: 2.15.9 Node: 4.5.0 Steps: 1) Copy the tiapp.xml from the description and the app.js:
        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, clear])
        win.add([bar, scrollView]);
        win.open();
        
    Step 2) Build and Run application Step 3) Force quit the app Step 4) Use the shortcut (named Gallery) to open the app Step 5) Confirm it logs LAUNCH INTENT .. WITH EXTRA: gallery as expected Step 6) Move the app to the background Step 7) Use the shortcut again Step 8) Confirm it logs NEW INTENT .. WITH EXTRA: gallery as expected This Ticket however will be kept open for the new release to make sure it still fixed!
  52. Hans Knöchel 2017-01-23

    PR (6_0_X): https://github.com/appcelerator/titanium_mobile/pull/8776
  53. Andy Waldman 2017-01-23

    Tested 23th january 2017: After creating a new classic app with environment: MacOS:10.12.1 XCODE: 8.2.1 GM (golden master) APPC CLI Core: 6.1.0 APPC CLI NPM: 4.2.8 SDK: 6.0.2.v20170123062940 Studio build: 4.8.1.201612050850 NPM: 2.15.9 Node: 4.5.0 Step 1) Copy the tiapp.xml from the description and the app.js:
        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, clear])
        win.add([bar, scrollView]);
        win.open();
        
    Step 2) Build and Run the application :: on running the application find bellow the logs for the errors that occur for it.
        [INFO] :   DatabaseHelper: No value in database for platform key: 'hardware_machine_id' returning supplied default ''
        [WARN] :   V8Object: (main) [376,406] Runtime disposed, cannot set property 'userAgent'
        [INFO] :   TiApplication: (main) [29,435] Titanium Javascript runtime: v8
        [INFO] :   TiRootActivity: (main) [0,0] checkpoint, on root activity create, savedInstanceState: null
        [INFO] :   TiRootActivity: (main) [0,0] checkpoint, on root activity resume. activity = com.myapp.timob20459a.Timob204593Activity@2298f31
        [ERROR] :  TiApplication: (main) [80,80] Sending event: exception on thread: main msg:java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp.timob20459a/org.appcelerator.titanium.TiActivity}: java.lang.ClassCastException: java.lang.Object[] cannot be cast to org.appcelerator.titanium.proxy.TiViewProxy; Titanium 6.0.2,2017/01/23 06:30,undefined
        [ERROR] :  TiApplication: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp.timob20459a/org.appcelerator.titanium.TiActivity}: java.lang.ClassCastException: java.lang.Object[] cannot be cast to org.appcelerator.titanium.proxy.TiViewProxy
        [ERROR] :  TiApplication: 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
        [ERROR] :  TiApplication: 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
        [ERROR] :  TiApplication: 	at android.app.ActivityThread.-wrap12(ActivityThread.java)
        [ERROR] :  TiApplication: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
        [ERROR] :  TiApplication: 	at android.os.Handler.dispatchMessage(Handler.java:102)
        [ERROR] :  TiApplication: 	at android.os.Looper.loop(Looper.java:154)
        [ERROR] :  TiApplication: 	at android.app.ActivityThread.main(ActivityThread.java:6119)
        [ERROR] :  TiApplication: 	at java.lang.reflect.Method.invoke(Native Method)
        [ERROR] :  TiApplication: 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
        [ERROR] :  TiApplication: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
        [ERROR] :  TiApplication: Caused by: java.lang.ClassCastException: java.lang.Object[] cannot be cast to org.appcelerator.titanium.proxy.TiViewProxy
        [ERROR] :  TiApplication: 	at org.appcelerator.titanium.proxy.TiViewProxy.setActivity(TiViewProxy.java:1044)
        [ERROR] :  TiApplication: 	at ti.modules.titanium.ui.WindowProxy.windowCreated(WindowProxy.java:200)
        [ERROR] :  TiApplication: 	at org.appcelerator.titanium.TiActivityWindows.windowCreated(TiActivityWindows.java:33)
        [ERROR] :  TiApplication: 	at org.appcelerator.titanium.TiBaseActivity.windowCreated(TiBaseActivity.java:559)
        [ERROR] :  TiApplication: 	at org.appcelerator.titanium.TiBaseActivity.onCreate(TiBaseActivity.java:673)
        [ERROR] :  TiApplication: 	at org.appcelerator.titanium.TiActivity.onCreate(TiActivity.java:20)
        [ERROR] :  TiApplication: 	at android.app.Activity.performCreate(Activity.java:6679)
        [ERROR] :  TiApplication: 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
        [ERROR] :  TiApplication: 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
        [ERROR] :  TiApplication: 	... 9 more
        
    I ran the application with the 6.1.0.v20170123100346 SDK and everything was ok I then had Lokesh verify this and he also got the same out come. From these findings I will re-open the ticket
  54. Gary Mathews 2017-01-23

    [~awaldman] The test case passes a view array into bar.add(...) and win.add(...), making use of this PR https://github.com/appcelerator/titanium_mobile/pull/8452 We can either, backport this feature into 6.0.2 or update the test case to not use this feature:
        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();
        
  55. Andy Waldman 2017-01-23

    After testing using the app.js file :
        
        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();
        
    The SDK: 6.0.2.v20170123062940 Works and so I will close this ticket [~gmathews]
  56. Gary Mathews 2017-01-25

  57. Andy Waldman 2017-01-27

    Tested 27th january 2017: After creating a new classic app with environment: MacOS:10.12.1 XCODE: 8.2.1 GM (golden master) APPC CLI Core: 6.1.0 APPC CLI NPM: 4.2.8 SDK: 6.0.2.v20170126173908 Studio build: 4.8.1.201612050850 NPM: 2.15.9 Node: 4.5.0 Step 1) Copy the tiapp.xml from the description and the app.js:
        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();
        
    tiapp.xml add this ...:
        <android xmlns:android="http://schemas.android.com/apk/res/android">
        		<manifest>
        			<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
        		</manifest>
        	</android>
        
    Step 2) Build and Run application Step 3) Force quit the app Step 4) Use the shortcut (named Gallery) to open the app Step 5) Confirm it logs LAUNCH INTENT .. WITH EXTRA: gallery as expected Step 6) Move the app to the background Step 7) Use the shortcut again Step 8) Confirm it logs NEW INTENT .. WITH EXTRA: gallery as expected I can confirm this fix has worked with the latest build of the 6.0.2 SDK and so will close this ticket
  58. Michael Kazmier 2017-03-01

    I have been testing this in 6.0.2.GA and I do not think this is working correctly. Let me explain quickly: 1. Per the instructions, I have added the event listener and the debug statements. 2. When we first launch the app, we get the correct newintent event and can see the extras we pass in. [DEBUG] [android, 6.0.1, 192.168.10.146] ----------------------------------- EVENT newintent ----------------------------------- [DEBUG] [android, 6.0.1, 192.168.10.146] NEW INTENT {"type":null,"packageName":"com.test.mobile","className":"org.appcelerator.titanium.TiActivity","action":null,"flags":0,"data":null,"apiName":"Ti.Android.Intent","bubbleParent":true} WITH EXTRA: com.kiloo.subwaysurf 2. But if the is running in the background, and (using a different app) we fire a new activity/intent with different extras, we still get the newinitent event BUT we don't get the new extras: [DEBUG] [android, 6.0.1, 192.168.10.146] ----------------------------------- EVENT newintent ----------------------------------- [DEBUG] [android, 6.0.1, 192.168.10.146] NEW INTENT {"type":null,"packageName":"com.test.mobile","className":"org.appcelerator.titanium.TiActivity","action":null,"flags":0,"data":null,"apiName":"Ti.Android.Intent","bubbleParent":true} WITH EXTRA: null
  59. Nikita Radaev 2017-03-15

    Why is this issue being closed? It clearly is not working.
  60. Hans Knöchel 2017-03-15

    [~nradaev] It was closed as part of the 6.0.2.GA release. All issues since then have to be handled in a new ticket to keep track of the release versions and QE-validations. The support team will create a new ticket after checking with our QE department.
  61. Abdiel Aviles 2017-03-15

    [~hansknoechel] Can you please post here the new ticket? I've been closely following this issue and would like to get notified once resolved.

JSON Source