2

I am using camera in my application it's working fine in my application. But we have tested in rooted tablets there is all apps have been stripped out of tablets including the native media gallery. Now the problem is when we try to take videos from these rooted tablets app will crash. I have the following stack trace:

java.lang.RuntimeException: getParameters failed (empty parameters)
       at android.hardware.Camera.native_getParameters(Camera.java)
       at android.hardware.Camera.getParameters(Camera.java:1464)
       at com.x.y.video.Preview.onTouchEvent(Preview.java:404)
       at android.view.View.dispatchTouchEvent(View.java:7392)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2235)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1978)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2235)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1978)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2235)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1978)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2235)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1978)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2235)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1978)
       at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2177)
       at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1482)
       at android.app.Activity.dispatchTouchEvent(Activity.java:2483)
       at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2125)
       at android.view.View.dispatchPointerEvent(View.java:7577)
       at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3376)
       at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:3308)
       at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:4421)
       at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:4399)
       at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:4505)
       at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:178)
       at android.os.MessageQueue.nativePollOnce(MessageQueue.java)
       at android.os.MessageQueue.next(MessageQueue.java:125)
       at android.os.Looper.loop(Looper.java:124)
       at android.app.ActivityThread.main(ActivityThread.java:4949)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:511)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1043)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:810)
       at dalvik.system.NativeStart.main(NativeStart.java)

And this indicates error in following line

Camera.Parameters parameters = camera.getParameters();

How can i solve this issue. Please anyone help me.

I found similar question like this in StackOverFlow but no solution works for me.

EDIT I have add sample code

if( camera != null && !this.using_face_detection ) {
            Camera.Parameters parameters = camera.getParameters();
            String focus_mode = parameters.getFocusMode();
            this.has_focus_area = false;
            // getFocusMode() is documented as never returning null, however I've had null pointer exceptions reported in Google Play
            if( parameters.getMaxNumFocusAreas() != 0 && focus_mode != null && ( focus_mode.equals(Camera.Parameters.FOCUS_MODE_AUTO) || focus_mode.equals(Camera.Parameters.FOCUS_MODE_MACRO) || focus_mode.equals(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE) || focus_mode.equals(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO) ) ) {
                if( MyDebug.LOG )
                    Log.d(TAG, "set focus (and metering?) area");
                this.has_focus_area = true;
                this.focus_screen_x = (int)event.getX();
                this.focus_screen_y = (int)event.getY();

                ArrayList<Camera.Area> areas = getAreas(event.getX(), event.getY());
                parameters.setFocusAreas(areas);

                // also set metering areas
                if( parameters.getMaxNumMeteringAreas() == 0 ) {
                    if( MyDebug.LOG )
                        Log.d(TAG, "metering areas not supported");
                }
                else {
                    parameters.setMeteringAreas(areas);
                }

                setCameraParameters(parameters);
            }
            else if( parameters.getMaxNumMeteringAreas() != 0 ) {
                if( MyDebug.LOG )
                    Log.d(TAG, "set metering area");
                // don't set has_focus_area in this mode
                ArrayList<Camera.Area> areas = getAreas(event.getX(), event.getY());
                parameters.setMeteringAreas(areas);

                setCameraParameters(parameters);
            }
        }
Amsheer
  • 7,046
  • 8
  • 47
  • 81
  • look into this [post](http://stackoverflow.com/questions/14941625/correct-handling-of-exception-getparameters-failed-empty-parameters) – Sagar Pilkhwal Sep 10 '14 at 06:32
  • I read it. They are mention call before camera.unlock(). that doesn't help. – Amsheer Sep 10 '14 at 06:38
  • can you post some of your code? – Sagar Pilkhwal Sep 10 '14 at 06:40
  • See the edit of my question – Amsheer Sep 10 '14 at 06:45
  • Smells like a bug in device. Can you do _something_ with this camera after you open it? Can you **setParameters()**? Does the tablet have a camera app? I not, maybe you can install some apk that works with this camera? – Alex Cohn Sep 10 '14 at 09:04
  • yes all apps have been stripped out of tablets including the camera. Is it any way to solve this issue?. These are rooted tablets. – Amsheer Sep 10 '14 at 09:54
  • In my case, I was getting this on the stock Camera app on an Android API 22 emulator. I fixed it by using the 32bit x86 OS image on the emulator instead of the 64bit x86 one. – Joshua Pinter Oct 30 '17 at 02:35

0 Answers0