It doesn't appear that closeActivity() is ever being called....

----------------------------------------------------------------------
There are only 10 types of people in the world...
Those who know binary and those who don't.
----------------------------------------------------------------------


On Fri, Oct 16, 2009 at 9: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