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

Android: ShortcutItem not being updated based on "id"

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: Release 8.0.0
    • Fix Version/s: Release 8.1.0
    • Component/s: None
    • Environment:

      Ti 8.0.0.GA
      Android minSdkVersion="19", targetSdkVersion="28"

    • Story Points:
      8
    • Sprint:
      2019 Sprint 11, 2019 Sprint 12, 2019 Sprint 13

      Description

      on iOS, there is a method removeAllDynamicShortcuts() that allows me to remove all shortcuts and create new ones.

      on Android, the only method we have is createShortcutItem(). There is no update or remove of any kind.

      In Ti.Slack, Joshua Quick mentioned that, by looking at the code, he thought all we needed to do was use the createShortcutItem() method again and as long as the "id" was the same - it would be overridden or replaced.

      That is not happening and is resulting in an error, "Max number of dynamic shortcuts exceeded".

      We have to have a way to remove or at a minimum replace an existing shortcut.

      CODE:

          var mobileShortcut;
          var workShortcut;
          var emailShortcut;
          function testAndroidShortcut() {
              emailShortcut = Ti.UI.createShortcutItem({
                  id: 'email_address',
                  title: "Email",
                  description: 'Email',
                  icon: Ti.Android.R.drawable.ic_menu_send
              });
              workShortcut = Ti.UI.createShortcutItem({
                  id: 'work_phone',
                  title: "Work",
                  description: 'Work',
                  icon: Ti.Android.R.drawable.ic_menu_call
              });
              mobileShortcut = Ti.UI.createShortcutItem({
                  id: 'mobile_phone',
                  title: "Mobile",
                  description: 'Mobile',
                  icon: Ti.Android.R.drawable.ic_menu_call
              });
          }
       
          for (var i = 0; i < 7; i++) {
              testAndroidShortcut();
          }
      

      ERROR:

      [ERROR] KrollProxy: (main) [22,12720] Error creating proxy
      [ERROR] KrollProxy: java.lang.IllegalArgumentException: Max number of dynamic shortcuts exceeded
      [ERROR] KrollProxy:     at android.os.Parcel.createException(Parcel.java:1970)
      [ERROR] KrollProxy:     at android.os.Parcel.readException(Parcel.java:1934)
      [ERROR] KrollProxy:     at android.os.Parcel.readException(Parcel.java:1884)
      [ERROR] KrollProxy:     at android.content.pm.IShortcutService$Stub$Proxy.setDynamicShortcuts(IShortcutService.java:521)
      [ERROR] KrollProxy:     at android.content.pm.ShortcutManager.setDynamicShortcuts(ShortcutManager.java:336)
      [ERROR] KrollProxy:     at ti.modules.titanium.ui.ShortcutItemProxy.show(ShortcutItemProxy.java:127)
      [ERROR] KrollProxy:     at ti.modules.titanium.ui.ShortcutItemProxy.handleCreationDict(ShortcutItemProxy.java:111)
      [ERROR] KrollProxy:     at org.appcelerator.kroll.KrollProxy.handleCreationArgs(KrollProxy.java:205)
      [ERROR] KrollProxy:     at org.appcelerator.kroll.KrollProxy.setupProxy(KrollProxy.java:131)
      [ERROR] KrollProxy:     at org.appcelerator.kroll.KrollProxy.createProxy(KrollProxy.java:140)
      [ERROR] KrollProxy:     at org.appcelerator.kroll.runtime.v8.V8Function.nativeInvoke(Native Method)
      [ERROR] KrollProxy:     at org.appcelerator.kroll.runtime.v8.V8Function.callSync(V8Function.java:55)
      [ERROR] KrollProxy:     at org.appcelerator.kroll.runtime.v8.V8Function.call(V8Function.java:41)
      [ERROR] KrollProxy:     at ti.modules.titanium.TitaniumModule$Timer.run(TitaniumModule.java:167)
      [ERROR] KrollProxy:     at android.os.Handler.handleCallback(Handler.java:873)
      [ERROR] KrollProxy:     at android.os.Handler.dispatchMessage(Handler.java:99)
      [ERROR] KrollProxy:     at android.os.Looper.loop(Looper.java:214)
      [ERROR] KrollProxy:     at android.app.ActivityThread.main(ActivityThread.java:7032)
      [ERROR] KrollProxy:     at java.lang.reflect.Method.invoke(Native Method)
      [ERROR] KrollProxy:     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
      [ERROR] KrollProxy:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)
      [ERROR] KrollProxy: Caused by: android.os.RemoteException: Remote stack trace:
      [ERROR] KrollProxy:     at com.android.server.pm.ShortcutService.enforceMaxActivityShortcuts(ShortcutService.java:1702)
      [ERROR] KrollProxy:     at com.android.server.pm.ShortcutPackage.enforceShortcutCountsBeforeOperation(ShortcutPackage.java:1104)
      [ERROR] KrollProxy:     at com.android.server.pm.ShortcutService.setDynamicShortcuts(ShortcutService.java:1849)
      [ERROR] KrollProxy:     at android.content.pm.IShortcutService$Stub.onTransact(IShortcutService.java:64)
      [ERROR] KrollProxy:     at android.os.Binder.execTransact(Binder.java:739)
      [ERROR] KrollProxy:
      

        Attachments

          Activity

            People

            • Assignee:
              gmathews Gary Mathews
              Reporter:
              amwinsauto Adam Armstrong
              Reviewer:
              Joshua Quick
              Tester:
              Lokesh Choudhary
            • Watchers:
              12 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