Monday, March 19, 2012

[android-developers] Re: onActivityResult not being called

Below code is some odd.
Intent().setClass(BrewJournalEdit.this, BaseIngredientEdit.class); 

How about changing to below code?

Intent().setClass(BaseIngredientEdit.this, BrewJournalEdit.class); 


2012년 3월 20일 화요일 오후 12시 1분 48초 UTC+9, Joey Selah 님의 말:
I'm having an issue where the onActivityResult() handler isn't being
hit.  I'm launching the activity with startActivityForResult() but
onActivityResult() is never being hit.  I'm partially wondering if
it's launching as a new task instead of a sub task.  And if I'm not
mistaken, new classes won't return to onActivityResult().  But I could
be wrong.  Let me know if you see anything missing in my code.  I will
admit that this is a stripped down version of my code but all the
relevant code should be included below.  Any help would be
appreciated.  Thanks!


public class BaseIngredientEdit extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.brew_journal_edit);

        baseIngredientButton.setOnClickListener(new
View.OnClickListener() {
            public void onClick(View view) {
                    Intent intent = new
Intent().setClass(BrewJournalEdit.this, BaseIngredientEdit.class);
                    int requestCode = 0;
                startActivityForResult(intent, requestCode);
            }
        });

    @Override
    protected void onActivityResult(int requestCode, int resultCode,
Intent data)
    {
            if(resultCode == 0)
            {

            }
    }
}



public class BrewJournalEdit extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.brew_base_ingredients_edit);

        Button confirmButton = (Button) findViewById(R.id.confirm);

        confirmButton.setOnClickListener(new View.OnClickListener() {

            public void onClick(View view) {
                setResult(RESULT_OK);
                finish();
            }

        });
}

--
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
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment