This ought to be simple but I can't figure it out. I want to use the
Camera app to take a picture, then I want to view it in a picture
viewer such as Gallery. Since the camera in the emulator doesn't work
yet, I'm doing this on a Motorola Droid device. I do the following in
my application (captureImage is called from a button click):

    public void captureImage(View view)
    {
        ContentValues values = new ContentValues();
        values.put(Media.TITLE, "My demo image");
        values.put(Media.DESCRIPTION, "Image Captured by Camera via an
Intent");

        myPicture = getContentResolver().insert
(Media.EXTERNAL_CONTENT_URI, values);

        Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        i.putExtra(MediaStore.EXTRA_OUTPUT, myPicture);

        startActivityForResult(i, 0);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
        if(requestCode==0 && resultCode==Activity.RESULT_OK)
        {
             Intent inn = new Intent(Intent.ACTION_VIEW);
             Log.v(TAG, "myPicture is " + myPicture.toString());
             inn.setData(myPicture);
             startActivity(inn);
        }
    }

The Camera activity launches, I take a picture (which does get saved
to the SD card), I click on Done. Then I get this line in my LogCat:

myPicture is content://media/external/images/media/53

Then I get a forced close on my app with the following stack trace:

Uncaught handler: thread main exiting due to uncaught exception
java.lang.RuntimeException: Failure delivering result ResultInfo
{who=null, request=0, result=-1, data=null}
to activity {Activity}: android.content.ActivityNotFoundException: No
Activity found to
handle Intent { act=android.intent.action.VIEW dat=content://media/
external/images/media/53 }
    at android.app.ActivityThread.deliverResults(ActivityThread.java:
3287)
    at android.app.ActivityThread.handleSendResult(ActivityThread.java:
3329)
    at android.app.ActivityThread.access$2700(ActivityThread.java:119)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:
1851)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:123)
    at android.app.ActivityThread.main(ActivityThread.java:4310)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:521)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:860)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: android.content.ActivityNotFoundException: No Activity
found to handle Intent {
act=android.intent.action.VIEW dat=content://media/external/images/
media/53 }
    at android.app.Instrumentation.checkStartActivityResult
(Instrumentation.java:1408)
    at android.app.Instrumentation.execStartActivity
(Instrumentation.java:1378)
    at android.app.Activity.startActivityForResult(Activity.java:2749)
    at android.app.Activity.startActivity(Activity.java:2855)
    at com.record.image.MainActivity.onActivityResult
(MainActivity.java:51)
    at android.app.Activity.dispatchActivityResult(Activity.java:3828)
    at android.app.ActivityThread.deliverResults(ActivityThread.java:
3283)
    ... 11 more

I'm thinking that my local Uri object myPicture is missing something
because I'm not refreshing it after the picture is actually taken,
that it's still a shell of an object and not a full-fledged picture.
So how does one go about getting a good Uri to pass to Gallery? If I
don't pass the Uri to the Camera, it will return to me a small version
of the bitmap and not really what I want to view. If I query the
ContentResolver it will return a Cursor. Do I build a new Uri from the
Cursor? Or can I somehow tweak my Uri to get checkStartActivityResult
to find Gallery for me? Thanks for your help.

- dave

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to