Hello
I have been having this difficulty too. An intent started with
startActivityForResult() exiting through this code...does not return
its load of Extra data.
    String s = persistWidgetData();
    Intent i = new Intent();
    i.putExtra("returnValue", s);
    i.putExtra("TestIntReturn",3142);
    Log.e("SettingsDialog", String.format("in okButtonCallback = %s
",s));
    setResult(RESULT_OK);
    finish();

However the following code in another java file in the same program
does in fact work...
                Intent iwpa = new Intent();
                iwpa.putExtra("returnValue", Constants.CANCEL);
                setResult(79, iwpa);
                WoundPicturesAudio.this.finish(); // back to the menu

Share your experiences!!!


On Oct 16, 8:22 am, mellamanjefe <mellamanj...@gmail.com> wrote:
> I have 2 activities which I need to share data between. The data
> passes from the first (parent) activity to the child properly using
> the intent and unpacking the bundle in the child class. However when
> the child activity ends and onActivityResult() is called in the parent
> the returned intent is null. Here is a snippet of the code involved:
>
> // In parent class Parent.java
>
> /** Called when the activity is first created. */
>     @Override
>     public void onCreate(Bundle savedInstanceState) {
>         super.onCreate(savedInstanceState);
>         setContentView(R.layout.main);
>
>         configureButtonFunctionality();
>     }
>
>     private void configureButtonFunctionality()
>     {
>         Button b = (Button) findViewById(R.id.UpdateVelocityButton);
>         b.setOnClickListener(new View.OnClickListener() {
>
>                         public void onClick(View v) {
>                                 // TODO Auto-generated method stub
>                                 
> launchAviationActivity(Activities.Velocity.ordinal());
>
>                         }
>                 });
>     }
>
>     private Intent setIntentDataForActivities(int activity)
>     {
>         currentVelocity = 123.0; // privately defined class member.
>         Intent i = new Intent(this, Child.class);
>         i.putExtra("Velocity", currentVelocity);
>         return(i);
>     }
>
>     private void launchChildActivity(int a)
>     {
>         startActivityForResult(setIntentDataForActivities(a), a);
>     }
>
>     @Override
>     protected void onActivityResult(int requestCode, int resultCode,
> Intent intent)
>     {
>  /////////////////////////////////////////////////// Here is where the
> intent returns from the Child class but is null... /////////////////
>         super.onActivityResult(requestCode, resultCode, intent);
>
>         if(requestCode == Activities.Velocity.ordinal())
>         {
>             currentVelocity = intent.getDoubleExtra("Velocity", 0.0);
>         }
>     }
>
> // In child class Child.java
>     protected void onCreate(Bundle savedInstanceState)
>     {
>         super.onCreate(savedInstanceState);
>
>         Intent i = this.getIntent();
>         Bundle b = i.getExtras();
>         currentVelocity = b.getDouble("Velocity"); // value is passed
> and received properly here.
>
>        ...............
>     }
>
>     private void closeActivity()
>     {
>         clearFields();
>
>         //Intent i = new Intent(); // Building the intent with either
> constructor does not make a difference in behavior
>         Intent i = new Intent(this, Parent.class);
>         i.putExtra("Velocity", currentVelocity);
>         setResult(RESULT_OK, i);
>         finish();
>     }
>
> I am new with Android and have ran out of explanations for this. Any
> assistance will be appreciated :).
>
> Thanks!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to