Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6772405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:32:44+00:00 2026-05-26T15:32:44+00:00

at android.hardware.Camera.native_setParameters(Native Method) at android.hardware.Camera.setParameters(Camera.java:647) at com.CameraApp.Preview.surfaceChanged(Preview.java:67) at android.view.SurfaceView.updateWindow(SurfaceView.java:538) at android.view.SurfaceView.dispatchDraw(SurfaceView.java:339) at android.view.ViewGroup.drawChild(ViewGroup.java:1638) at

  • 0
 at android.hardware.Camera.native_setParameters(Native Method) at                  
 android.hardware.Camera.setParameters(Camera.java:647) at com.CameraApp.Preview.surfaceChanged(Preview.java:67) at      
 android.view.SurfaceView.updateWindow(SurfaceView.java:538) at 
 android.view.SurfaceView.dispatchDraw(SurfaceView.java:339) at 
 android.view.ViewGroup.drawChild(ViewGroup.java:1638) at 
 android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367) at 
 android.view.ViewGroup.drawChild(ViewGroup.java:1638) at  
 android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367) at 
 android.view.ViewGroup.drawChild(ViewGroup.java:1638) at 
 android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367) at  
 android.view.View.draw(View.java:6743) at 
 android.widget.FrameLayout.draw(FrameLayout.java:352) at 
 android.view.ViewGroup.drawChild(ViewGroup.java:1640) at 
 android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367) at 
 android.view.View.draw(View.java:6743) at 
 android.widget.FrameLayout.draw(FrameLayout.java:352) at 
 com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1842) at 
 android.view.ViewRoot.draw(ViewRoot.java:1407) at 
 android.view.ViewRoot.performTraversals(ViewRoot.java:1163) at 
 android.view.ViewRoot.handleMessage(ViewRoot.java:1727) at 
 android.os.Handler.dispatchMessage(Handler.java:99) at 
 android.os.Looper.loop(Looper.java:123) at 
 android.app.ActivityThread.main(ActivityThread.java:4627) at 
 java.lang.reflect.Method.invokeNative(Native Method) at 
 java.lang.reflect.Method.invoke(Method.java:521) at 

I ran the app on 2.2 emulator also to check it. But it worked fine. can anyone please tell me why the error is occuring???

This code i used

    SurfaceHolder mHolder;
    public Camera camera;

    Preview(Context context) {
        super(context);

        // Install a SurfaceHolder.Callback so we get notified when the
        // underlying surface is created and destroyed.
        mHolder = getHolder();
        mHolder.addCallback(this);
        mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    }



    public void surfaceCreated(SurfaceHolder holder) {
        // The Surface has been created, acquire the camera and tell it where
        // to draw.
         camera = Camera.open();
        try {
            camera.setPreviewDisplay(holder);
        } catch (IOException exception) {
            camera.release();
            camera = null;
            // TODO: add more exception handling logic here
        }
    }

    public void surfaceDestroyed(SurfaceHolder holder) {
        // Surface will be destroyed when we return, so stop the preview.
        // Because the CameraDevice object is not a shared resource, it's very
        // important to release it when the activity is paused.
        camera.stopPreview();
        camera.release();
        camera = null;
    }

    public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
        // Now that the size is known, set up the camera parameters and begin
        // the preview.

        Camera.Parameters parameters = camera.getParameters();
        parameters.setPreviewSize(w, h);
        camera.setParameters(parameters);
        camera.startPreview();
    }

@Override
public void draw(Canvas canvas) {
        super.draw(canvas);
        Paint p= new Paint(Color.RED);
        Log.d(TAG,"draw");
        canvas.drawText("PREVIEW", canvas.getWidth()/2, canvas.getHeight()/2, p );
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T15:32:44+00:00Added an answer on May 26, 2026 at 3:32 pm

    Change this in your code.

    public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
        Camera.Parameters parameters = camera.getParameters();
        List<Camera.Size> previewSizes = parameters.getSupportedPreviewSizes();
    
        // You need to choose the most appropriate previewSize for your app
        Camera.Size previewSize = // .... select one of previewSizes here
    
        parameters.setPreviewSize(previewSize.width, previewSize.height);
        camera.setParameters(parameters);
        camera.startPreview();
    }
    

    thanks..

    If any Query remaining Then Tell me

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I take pictures using android.hardware.camera and I save them to the following location
I'm a newbie programmer for Android I was trying to start camera preview in
import android.hardware.Camera; import android.hardware.Camera.CameraInfo; CameraInfo cameraInfo = new CameraInfo(); for(int x=0; x < Camera.getNumberOfCameras();
I got the following code inside my templateApp.java: package com.android.templateApp; import android.app.Activity; import android.os.Bundle;
I'm using android.hardware.Camera to take photos. And this is my settings: Camera.Parameters p =
I have camera preview on my android app but when I add an 'id'
Android is based on Linux; can native Linux applications be run on Android?
i am making a app which takes photo on button click i have camera.java
i am fighting with android hardware backbutton now my question to you is can
My app has SEND_SMS and RECEIVE_SMS permissions, by publishing it gets android.hardware.telephony requirement. As

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.