I'm having a VERY similar problem, but trying to use the camera.

The camera opens, and i can "snap" a picture, but when i choose "Save" or
"Ok", depending on device, it hides all activities and returns to the device
home screen, although the app is still running in the background.  Now the
code i'm using came from:
http://achorniy.wordpress.com/2010/04/26/howto-launch-android-camera-using-intents/#comment-346,
and when i run it in JAVA, OnActivityResult IS called, but when I run it in
c#/mono, it is NOT called

Below is my code.

public void StartCamera()
        {
            Context context = this;

            //define the file-name to save photo taken by Camera activity
            String fileName = "new-photo-name.jpg";
            //create parameters for Intent with filename
            ContentValues values = new ContentValues();
            values.Put(MediaStore.Images.ImageColumns.Title, fileName);
            values.Put(MediaStore.Images.ImageColumns.Description, "Image
capture by camera");
            //imageUri is the current activity attribute, define and save it
for later usage (also in onSaveInstanceState)
            Android.Net.Uri imageUri = context.ContentResolver.Insert(
                    MediaStore.Images.Media.ExternalContentUri, values);

            //create new Intent
            Intent intent = new Intent(MediaStore.ActionImageCapture);
            intent.PutExtra(MediaStore.ExtraOutput, imageUri);
            intent.PutExtra(MediaStore.ExtraVideoQuality, 1);

            this.StartActivityForResult(intent, 1337);
        }

 protected override void OnActivityResult(int requestCode, Result
resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);
            Log.Info("HAGRID", "TIActivity Activity Result Called");
            Log.Info("HAGRID", "Activity Result, request code: " +
requestCode + " -- result code: " + resultCode + "");

            /*if (BiomeActivityResult != null)
                BiomeActivityResult(requestCode, resultCode, data);*/
        }


Can anyone enlighten me ?


Thanks,
Brian Matz
Software Architect
Mobile Epiphany


On Wed, Sep 14, 2011 at 8:47 AM, efontana <e...@fontanas.net> wrote:

> Wow! I ran into this myself not 20 minutes ago, to make it work, you have
> to
> do this, I had left off
> the SingleTop and the OnActivityResult was being called immediately.
>
> // I found this fix from:
>
> http://lblasa.wordpress.com/2011/06/16/android-onactivityresult-after-startactivityforresult-getting-called-immediately/
>
>  Intent i = new Intent();
>  i.SetClass(this, typeof(Activity2));
>  i.AddFlags(ActivityFlags.SingleTop);   // The SingleTop - makes it act
> Modal
>  StartActivityForResult(i, 0);
>
> --
> View this message in context:
> http://mono-for-android.1047100.n5.nabble.com/OnActivityResult-not-being-called-tp4802915p4803100.html
> Sent from the Mono for Android mailing list archive at Nabble.com.
> _______________________________________________
> Monodroid mailing list
> Monodroid@lists.ximian.com
>
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid
>
_______________________________________________
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

Reply via email to