Hello All

I've use startActivityForResult as it described in many examples but
it return 0 result code after start new Activity.

In main Activity I use such code for sub activity invocation

                Intent iShowVideo = new Intent(EventHandling.this, 
ShowVideo.class);
                startActivityForResult(iShowVideo, 
this.REQUEST_CODE_SHOW_VIDEO);

And such code for getting results.

        @Override
        protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
                // TODO Auto-generated method stub
                //super.onActivityResult(requestCode, resultCode, data);
                if(requestCode == REQUEST_CODE_SHOW_VIDEO){
                        if(resultCode == RESULT_CANCELED){
                                Toast toast = Toast.makeText(this, 
"onActivityResultCancel: " +
String.valueOf(resultCode), Toast.LENGTH_LONG);
                                toast.show();
                        }else{
                                Toast toast = Toast.makeText(this, 
"onActivityResult: " +
String.valueOf(resultCode), Toast.LENGTH_LONG);
                                toast.show();
                        }
                }
        }

Here is a part code from ShowVideo activity
        @Override
        protected void onCreate(Bundle savedInstanceState) {
                // TODO Auto-generated method stub
                super.onCreate(savedInstanceState);

                setContentView(R.layout.showvideo);
                //showDialog(DIALOG_YES_NO_MESSAGE);

        Button button = (Button)findViewById(R.id.btnOK);
        button.setOnClickListener(mOkListener);
        button = (Button)findViewById(R.id.btnCancel);
        button.setOnClickListener(mCancelListener);

        //setResult(RESULT_OK, (new Intent()).setAction("Test!"));
        }

    private OnClickListener mOkListener = new OnClickListener()
    {
        public void onClick(View v)
        {
            // To send a result, simply call setResult() before your
            // activity is finished.
            setResult(RESULT_OK, (new Intent()).setAction("Corky!"));
            finish();
        }
    };

This code should work according many examples. And it should return
RESULT_OK after btnOK clicked but after I click this button it only
closes ShowVideo  Activity.

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

Reply via email to