Re: Supporting extra parameters on the Intent object

I like this metadata field on the return type. Did we think of
examples for the passed intent data to have metadata as well? I know
we discussed passing those in MIME parameters.

On Sun, Jan 29, 2012 at 6:18 PM, James Hawkins <jhawkins@google.com> wrote:
> Many use cases require passing optional, extra parameters from the
> client to the service and vice versa.
>
> Consider an example client invoking the Pick intent: a web mail client
> using Pick for attachments.  The current implementation allows the
> user browse the file system and pick a file to attach: this file has a
> filename, and that filename is displayed in the UI.  Using the Pick
> intent, the mail client can receive, say, an image to attach, but
> currently there is no way to correlate a filename with the picked
> image.
>
> I propose following the precedence set by Android Intents [1] to solve
> this problem: add an optional |extras| dictionary to the Intent
> object.  Documentation for intent actions could specify handling of
> optional extra parameters, e.g., filename for Pick.
>
> [Constructor(in string action, in string type, in any data)]
> interface Intent {
>     readonly attribute DOMString action;
>     readonly attribute DOMString type;
>     readonly attribute any data;
>     readonly attribute Dictionary extras;  <--- Added
>     void postResult (any data, optional Dictionary extras);      <---
> |extras| added
>     void postFailure (any data);
> };
>
> Client:
>
> document.getElementById('attach').onclick = function() {
>   var intent = new Intent("http://webintents.org/pick", "*");
>  navigator.startActivity(intent, filePicked);
> });
>
> Service:
>
> if (window.intent) {
>  ....
>  window.intent.postResult(selectedFile, {filename: selectedFilename});
> }
>
>
> What do you think?
>
> [1] http://developer.android.com/reference/android/content/Intent.html,
> search for 'extras'.
>
> Thanks,
> James
>

Received on Monday, 30 January 2012 15:53:05 UTC