Hello all,
I'm new to Android development, and am a bit confused here.  I'm
hoping someone can help me out.  I hope I've got the correct list.
Anyway, I've got a very simple Activity, one EditText and one Button.
Lets call it MyActivity.  Now, when I click on the button on
MyActivity, I want to take a picture using the camera.  For the sake
of this e-mail, lets call the activity that gets spawned when I click
on the button CameraActivity.

Here is how I've setup my button:

                Button takePictureButton = (Button)
this.findViewById(R.id.receipt_take_picture_button);
                takePictureButton.setOnClickListener(new View.OnClickListener() 
{
                        public void onClick(View v) {
                                ContentValues values = new ContentValues();
                                values.put(Media.TITLE, "IMAGE");
                                values.put(Media.DESCRIPTION, "Image Captured 
by Camera");
                                Uri uri = 
getContentResolver().insert(Media.EXTERNAL_CONTENT_URI, values);
                                Intent i = new 
Intent("android.media.action.IMAGE_CAPTURE");
                                i.putExtra("output", uri);
                                startActivityForResult(i, 
ACTIVITY_TAKE_PICTURE_WITH_INTENT);
                        }
                });
As I understand it, click the button will cause MyActivity to start up
CameraActivity, which is just the default camera application, to take
a picture.  Because I've used startActivityForResult, when
CameraActivity finishes, MyActivity should be notified via it's
onActivityResult.  Below is how I've coded it up:

I've defined my onActivityResult as follows:

        @Override
        protected void onActivityResult(int requestCode, int resultCode, Intent 
data) {
                super.onActivityResult(requestCode, resultCode, data);
                switch (requestCode) {
                        case (ACTIVITY_TAKE_PICTURE_WITH_INTENT):
                                Log.d(TAG, "WOW!");
                        default:
                                break;
                }
        }

So, what has me confused is this:  I would expect onActivityResult to
be called AFTER I take a picture, i.e. when I click on the picture
button.  Instead, it seems to get called immediately:  I click on the
takeAPictureButton, the camera activity starts up at about the same
time the code in onActivityResult gets fired.  Am I missing something
here?

-- 
http://www.opgenorth.net

--~--~---------~--~----~------------~-------~--~----~
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