Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-19679

Android: Added additional type support for IntentProxy

    Details

    • Story Points:
      2
    • Sprint:
      2015 Sprint 24 SDK

      Description

      Issue Description

      Currently it is not possible to create a launcher shortcut programmatically using the Titanium platform. Titanium allows for the creation of an Android intent using Ti.Android.createIntent but the implementation of the putExtra method is incomplete. It currently only supports Java primitives. Creating a shortcut requires an intent and an image to be set. Ideally the following example should work:

      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); // Not currently possible
      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); // Not currently possible
       
      // Adds the shortcut to the home screen.
      Ti.Android.currentActivity.sendBroadcast(shortcutIntent);
      

      I have created a pull request that adds the missing input types.
      https://github.com/appcelerator/titanium_mobile/pull/7073

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                msamah Ashraf Abu (Inactive)
                Reporter:
                CollinPrice Collin Price
                Reviewer:
                Ashraf Abu (Inactive)
              • Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                    Git Source Code