I've been facing similar problems regarding the IOException - take
picture failed.
hreadid=3: thread exiting with uncaught exception (group=0x4000fe70)
E/AndroidRuntime( 339): Uncaught handler: thread main exiting due to
uncaught exception
E/AndroidRuntime( 339): java.lang.RuntimeException:
java.lang.reflect.InvocationTargetException
E/AndroidRuntime( 339): at com.android.internal.os.ZygoteInit.main
(ZygoteInit.java:540)
E/AndroidRuntime( 339): at dalvik.system.NativeStart.main(Native
Method)
E/AndroidRuntime( 339): Caused by:
java.lang.reflect.InvocationTargetException
E/AndroidRuntime( 339): at android.app.ActivityThread.main
(ActivityThread.java:3948)
E/AndroidRuntime( 339): at java.lang.reflect.Method.invokeNative
(Native Method)
E/AndroidRuntime( 339): at java.lang.reflect.Method.invoke
(Method.java:521)
E/AndroidRuntime( 339): at com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:782)
E/AndroidRuntime( 339): ... 2 more
E/AndroidRuntime( 339): Caused by: java.io.IOException: takePicture
failed
E/AndroidRuntime( 339): at android.hardware.Camera.native_takePicture
(Native Method)
E/AndroidRuntime( 339): at android.hardware.Camera.takePicture
(Camera.java:362)
E/AndroidRuntime( 339): at com.george.camera.CameraFinal.onKeyDown
(CameraFinal.java:661)
E/AndroidRuntime( 339): at android.view.KeyEvent.dispatch
(KeyEvent.java:893)
E/AndroidRuntime( 339): at android.app.Activity.dispatchKeyEvent
(Activity.java:1976)
E/AndroidRuntime( 339): at
com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent
(PhoneWindow.java:1679)
E/AndroidRuntime( 339): at
android.view.ViewRoot.deliverKeyEventToViewHierarchy(ViewRoot.java:
2188)
E/AndroidRuntime( 339): at android.view.ViewRoot.handleFinishedEvent
(ViewRoot.java:2158)
E/AndroidRuntime( 339): at android.view.ViewRoot.handleMessage
(ViewRoot.java:1490)
E/AndroidRuntime( 339): at android.os.Handler.dispatchMessage
(Handler.java:99)
E/AndroidRuntime( 339): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 339): ... 6 more
It seems to be an intermittent problem, sometimes the camera works and
sometimes it doesn't. The line it crashes on is the camera.takepicture
bit, see below.
if (keyCode == KeyEvent.KEYCODE_CAMERA) {
mCamera.takePicture(null, null, mPictureCallback);
return true;
}
I've not set the raw pic callback or shutter call back, could this be
the problem?
Thanks,
George
On May 19, 8:53 pm, Bo <[email protected]> wrote:
> I just removed the default screen orientation in APIDemo menifest for
> com.example.android.apis.graphics.CameraPreview
> It's still displaying a rotated view.
>
> Best,
> Bo
>
> On May 12, 5:30 pm, indra <[email protected]> wrote:
>
> > Does1.5have support forcamerain portrait? Please post the code
> > sample.
>
> > Regards,
> > Indra
>
> > On Mar 16, 7:35 am, Iliyan Malchev <[email protected]> wrote:
>
> > > Can you attach the logcat output? Source code would also be helpful.
>
> > > On Thu, Mar 12, 2009 at 9:18 AM, crowcasso <[email protected]> wrote:
>
> > > > Currently the above code is crashing for me (even after fixing the 3
> > > > params instead of 2) when performing takePicture() with a IOException:
>
> > > > W/System.err( 1470): java.io.IOException: takePicture failed
> > > > W/System.err( 1470): at android.hardware.Camera.native_takePicture
> > > > (Native Method)
>
> > > > I've written a differentCameraapplication that crashes as well on
> > > > takePicture(). Is this a known issue? Any suggestions?
>
> > > > On Mar 10, 6:50 pm, Streets Of Boston <[email protected]> wrote:
> > > >> Maybe this piece of code won't work, but i'm writing an app that
> > > >> successfully uses thecamera.
> > > >> No crashes :) ... ... so far ... :=)
>
> > > >> On Feb 17, 1:35 am, cindy <[email protected]> wrote:
>
> > > >> > I tried google'scameraAPI sample code. I found there are 2 problems:
> > > >> > 1> It only can take picture in Landscape orientation
> > > >> > 2> After click the space "key", the application crashes. WOw:)
>
> > > >> > XML:
> > > >> > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/
> > > >> > android"
> > > >> > android:layout_width="fill_parent"
> > > >> > android:layout_height="fill_parent"
> > > >> > android:orientation="vertical">
> > > >> > <SurfaceView android:id="@+id/surface"
> > > >> > android:layout_width="fill_parent"
> > > >> > android:layout_height="10dip"
> > > >> > android:layout_weight="1">
> > > >> > </SurfaceView>
> > > >> > </LinearLayout>
> > > >> > Java code:
> > > >> > /**
> > > >> > * Copyright (c) 2007, Google Inc.
> > > >> > *
> > > >> > * Licensed under the Apache License, Version 2.0 (the "License");
> > > >> > * you may not use this file except in compliance with the License.
> > > >> > * You may obtain a copy of the License at
> > > >> > *
> > > >> > * http://www.apache.org/licenses/LICENSE-2.0
> > > >> > *
> > > >> > * Unless required by applicable law or agreed to in writing,
> > > >> > software
> > > >> > * distributed under the License is distributed on an "AS IS" BASIS,
> > > >> > * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> > > >> > implied.
> > > >> > * See the License for the specific language governing permissions
> > > >> > and
> > > >> > * limitations under the License.
> > > >> > */
>
> > > >> > package com.android.cameraapitest;
>
> > > >> > import android.app.Activity;
> > > >> > import android.content.Intent;
> > > >> > import android.graphics.Canvas;
> > > >> > import android.graphics.Paint;
> > > >> > import android.graphics.PixelFormat;
> > > >> > import android.graphics.Rect;
> > > >> > import android.net.Uri;
> > > >> > import android.os.Handler;
> > > >> > import android.os.Message;
> > > >> > import android.os.Bundle;
> > > >> > import android.provider.MediaStore.Images;
> > > >> > import android.provider.MediaStore.Video;
> > > >> > import android.view.Menu;
> > > >> > import android.view.MenuItem;
> > > >> > import android.view.SurfaceHolder;
> > > >> > import android.view.SurfaceView;
> > > >> > import android.view.KeyEvent;
> > > >> > import android.hardware.Camera;
>
> > > >> > import android.util.Log;
>
> > > >> > public class CameraApiTest extends Activity implements
> > > >> > SurfaceHolder.Callback
> > > >> > {
> > > >> > private static final String TAG = "CameraApiTest";
> > > >> > CameramCamera;
> > > >> > boolean mPreviewRunning = false;
>
> > > >> > public void onCreate(Bundle icicle)
> > > >> > {
> > > >> > super.onCreate(icicle);
>
> > > >> > Log.e(TAG, "onCreate");
>
> > > >> > getWindow().setFormat(PixelFormat.TRANSLUCENT);
>
> > > >> > setContentView(R.layout.camera_api_test);
> > > >> > mSurfaceView = (SurfaceView)findViewById(R.id.surface);
>
> > > >> > mSurfaceHolder = mSurfaceView.getHolder();
> > > >> > mSurfaceHolder.addCallback(this);
> > > >> > mSurfaceHolder.setType
> > > >> > (SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
> > > >> > }
>
> > > >> > public boolean onCreateOptionsMenu(android.view.Menu menu) {
> > > >> > MenuItem item = menu.add(0, 0, 0, "goto gallery");
> > > >> > item.setOnMenuItemClickListener(new
> > > >> > MenuItem.OnMenuItemClickListener() {
> > > >> > public boolean onMenuItemClick(MenuItem item) {
> > > >> > Uri target = Uri.parse("content://media/external/
> > > >> > images/media");
> > > >> > Intent intent = new Intent(Intent.ACTION_VIEW,
> > > >> > target);
> > > >> > startActivity(intent);
> > > >> > return true;
> > > >> > }
> > > >> > });
> > > >> > return true;
> > > >> > }
>
> > > >> > @Override
> > > >> > protected void onRestoreInstanceState(Bundle savedInstanceState)
> > > >> > {
> > > >> > super.onRestoreInstanceState(savedInstanceState);
> > > >> > }
>
> > > >> > Camera.PictureCallback mPictureCallback = new
> > > >> >Camera.PictureCallback() {
> > > >> > public void onPictureTaken(byte[] data,Camerac) {
> > > >> > Log.e(TAG, "PICTURE CALLBACK: data.length = " +
> > > >> > data.length);
> > > >> > mCamera.startPreview();
> > > >> > }
> > > >> > };
>
> > > >> > public boolean onKeyDown(int keyCode, KeyEvent event)
> > > >> > {
> > > >> > if (keyCode == KeyEvent.KEYCODE_BACK) {
> > > >> > return super.onKeyDown(keyCode, event);
> > > >> > }
>
> > > >> > if (keyCode == KeyEvent.KEYCODE_SPACE) {
> > > >> > mCamera.takePicture(null, mPictureCallback);
> > > >> > return true;
> > > >> > }
>
> > > >> > return false;
> > > >> > }
>
> > > >> > protected void onResume()
> > > >> > {
> > > >> > Log.e(TAG, "onResume");
> > > >> > super.onResume();
> > > >> > }
>
> > > >> > protected void onSaveInstanceState(Bundle outState)
> > > >> > {
> > > >> > super.onSaveInstanceState(outState);
> > > >> > }
>
> > > >> > protected void onStop()
> > > >> > {
> > > >> > Log.e(TAG, "onStop");
> > > >> > super.onStop();
> > > >> > }
>
> > > >> > public void surfaceCreated(SurfaceHolder holder)
> > > >> > {
> > > >> > Log.e(TAG, "surfaceCreated");
> > > >> > mCamera =Camera.open();
> > > >> > //mCamera.startPreview();
> > > >> > }
>
> > > >> > public void surfaceChanged(SurfaceHolder holder, int format, int
> > > >> > w, int h)
> > > >> > {
> > > >> > Log.e(TAG, "surfaceChanged");
>
> > > >> > // XXX stopPreview() will crash if preview is not running
> > > >> > if (mPreviewRunning) {
> > > >> > mCamera.stopPreview();
> > > >> > }
>
> > > >> > Camera.Parameters p = mCamera.getParameters();
> > > >> > p.setPreviewSize(w, h);
> > > >> > mCamera.setParameters(p);
> > > >> > mCamera.setPreviewDisplay(holder);
> > > >> > mCamera.startPreview();
> > > >> > mPreviewRunning = true;
> > > >> > }
>
> > > >> > public void surfaceDestroyed(SurfaceHolder holder)
> > > >> > {
> > > >> > Log.e(TAG, "surfaceDestroyed");
> > > >> > mCamera.stopPreview();
> > > >> > mPreviewRunning = false;
> > > >> > mCamera.release();
> > > >> > }
>
> > > >> > private SurfaceView mSurfaceView;
> > > >> > private SurfaceHolder mSurfaceHolder;
>
> > > >> > }- Hide quoted text -
>
> > > >> > - Show quoted text -
>
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---