Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: Release 5.2.0
    • Fix Version/s: Release 6.0.2
    • Component/s: Android
    • Labels:
      None
    • Environment:

      SDK 5.2.0

    • Story Points:
      13
    • Sprint:
      2017 Sprint 02 SDK

      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:

      1. Run the app
      2. Press the button to create a launcher shortcut
      3. Force quit the app
      4. Use the shortcut (named Gallery) to open the app
      5. Confirm it logs LAUNCH INTENT .. WITH EXTRA: gallery as expected
      6. Move the app to the background
      7. Use the shortcut again
      8. Confirm it does not log NEW INTENT .. WITH EXTRA: gallery as expected

      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

          Issue Links

            Activity

              People

              • Assignee:
                gmathews Gary Mathews
                Reporter:
                fokkezb Fokke Zandbergen
                Reviewer:
                Maggie Chen
                Tester:
                Andy Waldman
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-6983
                    Sync status:
                    ERROR
                    Last received:
                    Last sent:

                    Git Source Code