I'm trying to start the camera application and get an image back. I think I
should be able to get the image back in the OnActivityResult method.
Unfortunately, I am missing something as I don't seem to get anything back.
All of what look to be the interesting pieces of the data Intent seem to be
null. I suspect that the problems are on my end. Any suggestions on how to
get the image back when I take a picture? Wally using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
namespace Graphics
{
[Activity(Label = "Take Pictures Activity")]
public class takepictures : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Create your application here
SetContentView(Resource.Layout.takepictures);
Button btnCTP = FindViewById<Button>(Resource.Id.btnCloseTakePics);
btnCTP.Click += new EventHandler(btnCTP_Click_Close);
saveFullImage();
}
void btnCTP_Click_Close(object sender, EventArgs e)
{
this.Finish();
}
private static int TAKE_PICTURE = 1;
private Uri outputFileUri;
private void getThumbailPicture() {
Intent intent = new
Intent(Android.Provider.MediaStore.ActionImageCapture);
StartActivityForResult(intent, TAKE_PICTURE);
}
private void saveFullImage() {
Intent intent = new
Intent(Android.Provider.MediaStore.ActionImageCapture);
string file =
System.IO.Path.Combine(Android.OS.Environment.DirectoryDcim.ToString(),
"test.jpg");
var outputFileUri = Android.Net.Uri.Parse(file);
intent.PutExtra(Android.Provider.MediaStore.ExtraOutput,
outputFileUri);
StartActivityForResult(intent, TAKE_PICTURE);
}
protected override void OnActivityResult(int requestCode, Result
resultCode, Intent data)
{
base.OnActivityResult(requestCode, resultCode, data);
if (requestCode == TAKE_PICTURE)
{
Uri imageUri = null;
// Check if the result includes a thumbnail Bitmap
if (data != null)
{
if (data.HasExtra("data"))
{
var thumbnail = data.GetParcelableArrayExtra("data");
// TODO Do something with the thumbnail
}
}
else
{
var outputFileUri =
data.GetParcelableArrayExtra("outputFileuri");
// TODO Do something with the full image stored
// in outputFileUri
}
}
}
}
} _______________________________________________
Monodroid mailing list
[email protected]
UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid