[TIMOB-2587] Android: Support setting true URIs for EXTRA_STREAM
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | Low |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2011-04-17T01:59:32.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 1.6.0 M05 |
Components | Android |
Labels | android, feature, intent, release-1.6.0 |
Reporter | Bill Dawson |
Assignee | Bill Dawson |
Created | 2011-04-15T03:23:39.000+0000 |
Updated | 2011-04-17T01:59:32.000+0000 |
Description
Our IntentProxy.getData
is implemented by returning
Intent.getDataString
("The same as getData(), but
returns the URI as an encoded String" [android docs]). This means
we can't then take that information and pass it back into a new
intent's EXTRA_STREAM field. (EXTRA_STREAM: "A content: URI holding
a stream of data associated with the Intent, used with ACTION_SEND
to supply the data being sent.").
This, in turn, means we can't use our new intents and such to do something like the following:
- Start the sound recorder activity and get the Uri to the recorded sound file back.
- Pass that uri to a picker for ACTION_SEND (so as to send the audio file to somebody.)
For example, if you try the attached win.js and select the Gmail app as the sending mechanism, Gmail crashes with
W/Bundle (30615): Key android.intent.extra.STREAM expected Parcelable but value was a java.lang.String. The default value <null> was returned.
W/Bundle (30615): Attempt to cast generated internal exception:
W/Bundle (30615): java.lang.ClassCastException: java.lang.String
Attachments
File | Date | Size |
---|---|---|
win.js | 2011-04-15T03:23:40.000+0000 | 2143 |
@Marshall, in
IntentProxy.putExtra
we could check ifkey == Intent.EXTRA_STREAM && (value instanceof String)
and then set it to a URI. But maybe we need a less-hacky, more general solution? (I haven't looked at allEXTRA
s to see if others of them expect "non-primitive" data types.)You can assign back to me after answer.
The formatting of my commit got messed up, here's the commit that fixed this:
https://github.com/appcelerator/titanium_mobile/commit/f4d42cf4d2e1ca7bbf3a7ca2e987e27c778191e7"> https://github.com/appcelerator/titanium_mobile/commit/f4d42cf4d2e1...
test used to verify this:
verified on droid2 2.2
Could you extend the test example in order to create a new file with the recorded audio? How would soundUri be used in this case?
Andre Carregal, check out this gist for an example of how to save the response to a file. It works on videos, but the exact same thing can be applied to sound recording as well. What you want is towards the end of the gist:
https://gist.github.com/832488">https://gist.github.com/832488