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

Android: cannot retrieve EXTRA_STREAM from Intent (no getUriExtra)

    Details

      Description

      {html}<div><p>I'm using Titanium Mobile 1.5/1.6's support for native Android
      intents and activities to let our StatusNet Mobile app accept text
      and image attachments from other social networking apps and the
      system Gallery and Camera apps.</p>
      <p>Unfortunately I'm having some trouble accepting images, which
      are attached as a Uri object in the EXTRA_STREAM extra field.
      Calling intent.getStringExtra(Ti.Android.EXTRA_STREAM) fails,
      because the returned object is a Uri, not a string:</p>
      <pre>
      <code>W/Bundle ( 1569): Key android.intent.extra.STREAM expected String but value was a android.net.Uri$HierarchicalUri. The default value <null> was returned.
      W/Bundle ( 1569): Attempt to cast generated internal exception:
      W/Bundle ( 1569): java.lang.ClassCastException: android.net.Uri$HierarchicalUri
      W/Bundle ( 1569): at android.os.Bundle.getString(Bundle.java:1040)
      W/Bundle ( 1569): at android.content.Intent.getStringExtra(Intent.java:3368)
      W/Bundle ( 1569): at org.appcelerator.titanium.proxy.IntentProxy.getStringExtra(IntentProxy.java:239)
      W/Bundle ( 1569): at org.appcelerator.titanium.proxy.IntentProxyBindingGen$3.invoke(IntentProxyBindingGen.java:187)
      W/Bundle ( 1569): at org.appcelerator.kroll.KrollMethod.call(KrollMethod.java:51)
      W/Bundle ( 1569): at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1711)
      W/Bundle ( 1569): at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:854)
      W/Bundle ( 1569): at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164)
      W/Bundle ( 1569): at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:426)
      W/Bundle ( 1569): at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3161)
      W/Bundle ( 1569): at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:162)
      W/Bundle ( 1569): at org.appcelerator.titanium.kroll.KrollCallback.callSync(KrollCallback.java:139)
      W/Bundle ( 1569): at org.appcelerator.titanium.kroll.KrollCallback.callSync(KrollCallback.java:113)
      W/Bundle ( 1569): at org.appcelerator.titanium.kroll.KrollCallback.callSync(KrollCallback.java:108)
      W/Bundle ( 1569): at org.appcelerator.titanium.kroll.KrollCallback.callSync(KrollCallback.java:104)
      W/Bundle ( 1569): at org.appcelerator.kroll.KrollProxy.fireSingleEvent(KrollProxy.java:629)
      W/Bundle ( 1569): at org.appcelerator.kroll.KrollEventManager$KrollListener.invoke(KrollEventManager.java:143)
      W/Bundle ( 1569): at org.appcelerator.kroll.KrollEventManager.dispatchEvent(KrollEventManager.java:273)
      W/Bundle ( 1569): at org.appcelerator.kroll.KrollProxy.fireSyncEvent(KrollProxy.java:600)
      W/Bundle ( 1569): at org.appcelerator.titanium.TiBaseActivity.onCreate(TiBaseActivity.java:294)
      W/Bundle ( 1569): at org.appcelerator.titanium.TiLaunchActivity.onCreate(TiLaunchActivity.java:97)
      W/Bundle ( 1569): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
      W/Bundle ( 1569): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
      W/Bundle ( 1569): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
      W/Bundle ( 1569): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
      W/Bundle ( 1569): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
      W/Bundle ( 1569): at android.os.Handler.dispatchMessage(Handler.java:99)
      W/Bundle ( 1569): at android.os.Looper.loop(Looper.java:123)
      W/Bundle ( 1569): at android.app.ActivityThread.main(ActivityThread.java:4627)
      W/Bundle ( 1569): at java.lang.reflect.Method.invokeNative(Native Method)
      W/Bundle ( 1569): at java.lang.reflect.Method.invoke(Method.java:521)
      W/Bundle ( 1569): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
      W/Bundle ( 1569): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
      W/Bundle ( 1569): at dalvik.system.NativeStart.main(Native Method)</code>
      </pre>
      <p>I notice in ticket <a href="/projects/32238/tickets/2587" title=
      "Ticket #2587">#2587</a>, someone encountered the same problem when
      <em>creating</em> such intents to send to other applications, and
      an Intent.putUriExtra() was added to accommodate it, converting
      from a string parameter to a Uri.</p>
      <p>It looks like it would be helpful to add an
      Intent.getUriExtra(), or else tweak things such that there's some
      other clear way to retrieve it.</p></div>{html}

        Attachments

          Activity

            People

            • Assignee:
              ingo Ingo Muschenetz
              Reporter:
              brionvibber Brion Vibber
            • Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

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

                  Git Integration