It appears that the example applications from version 0.9 and the
migration tips are not consistent in their usage of the Intent that is
passed to setResult(..)

Example:

>From ReceiveResults.java in ApiDemos:
  setResult(RESULT_OK, (new Intent()).setAction("Corky!"));
and
  setResult(RESULT_OK, (new Intent()).setAction("Violet!"));

>From NoteEditor.java in NotePad:
  setResult(RESULT_OK, (new Intent()).setAction(mUri.toString()));

>From NotesList.java in NotePad:
  setResult(RESULT_OK, new Intent().setData(uri));

>From "M5 to 0.9 porting and migration tips":
  Bundle bundle = new Bundle();
  bundle.putString(TEST_STRING, "Corky!");
  Intent mIntent = new Intent();
  mIntent.putExtras(bundle);
  setResult(RESULT_OK, mIntent);

I believe that the NotesList.java is the only one which does it
correctly.

I'm not sure why "M5 to 0.9 porting and migration tips" bothers with
the Bundle. Isn't it more straight forward to just call
mIntent.putExtra(TEST_STRING, "Corky!");   ?

I think that ReceiveResults.java should have also called
putExtra(..):
  setResult(RESULT_OK, (new Intent()).putExtra(NAME, "Violet!"));

NoteEditor.java should have used putExtra(..):
  setResult(RESULT_OK, (new Intent()).putExtra(NAME,
mUri.toString()));
or better yet, it should have used the setData(..) method:
  setResult(RESULT_OK, (new Intent()).setData(mUri));

Many of these inconsistent usages stem from attempting to replace the
setResult(..) String parameter with the setAction(..) method's String.
IMHO, this hijacking of setAction(..) corrupts the clear purpose of
the Action String and so should be avoided.

Do I have it right? Am I missing something?

I'm interested in other people's take on this ambiguity because I see
it as an impediment to seamless integration between applications.

Originally blogged at: 
http://spencer.riddering.net/2008/8/21/inconsistent-usage-setresult-intent
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new Android 0.9 SDK beta!
http://android-developers.blogspot.com/2008/08/announcing-beta-release-of-android-sdk.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to