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 6883811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:25:46+00:00 2026-05-27T05:25:46+00:00

In my android app i am using the camera surface view as the background

  • 0

In my android app i am using the camera surface view as the background of the activity.what I want is that the camera should not get closed as soon as I move to another activity.I want camera view behind my each and every layout.But i cant restart the camera view bcoz it takes time to restart the camera.I want to run camera surface view running as the background of the activties.please help.

    Camera camera;
        SurfaceView surfaceView;
        SurfaceHolder surfaceHolder;
        boolean previewing = false;
        LayoutInflater controlInflater = null;

        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);        
             setContentView(R.layout.main);

             setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
             getWindow().setFormat(PixelFormat.UNKNOWN);
             surfaceView = (SurfaceView)findViewById(R.id.camerapreview);
             surfaceHolder = surfaceView.getHolder();
             surfaceHolder.addCallback(this);
             surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
             surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

            LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT);        
            LinearLayout mainLayout=new LinearLayout(this);
            mainLayout.setOrientation(LinearLayout.VERTICAL);               
            LayoutInflater layoutInflater = getLayoutInflater();        
            mainLayout.addView(layoutInflater.inflate(R.layout.dialpad,null));
            mainLayout.addView(layoutInflater.inflate(R.layout.allbuttons,null));

            this.addContentView(mainLayout, params);
}//end of oncreate method
public void surfaceChanged(SurfaceHolder holder, int format, int width,
            int height) {
        // TODO Auto-generated method stub
        if(previewing){
            camera.stopPreview();
            previewing = false;
        }

        if (camera != null){
            try {
                camera.setPreviewDisplay(surfaceHolder);
                camera.startPreview();
                previewing = true;
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }


    public void surfaceCreated(SurfaceHolder holder) {
        // TODO Auto-generated method stub
        camera = Camera.open();
    }


    public void surfaceDestroyed(SurfaceHolder holder) {
        // TODO Auto-generated method stub
        camera.stopPreview();
        camera.release();
        camera = null;
        previewing = false;


    }

this code i m using to create camera view. Please help me and respond soon.Thanks in advance.

  • 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-27T05:25:47+00:00Added an answer on May 27, 2026 at 5:25 am

    After doing a lot of searching i found the way to do my task.Simply start the camera by using any activity and then start the another activity.make sure that the activity u r starting is the transparent.Apply the transparent theme in android manifest file.The following link helped me to do it in this way.
    How do I create a transparent Activity on Android?

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

Sidebar

Related Questions

I've got an Android app which has a periodic background Service. I want this
I want to implement a share function like the camera app is using. final
I have an app in android using camera with opencv which runs for about
I am currently writing an app that within a certain activity, we want the
I want to implement a RESTful webservice for an Android App using JSON. Do
I have a web app, that also has an iPhone and Android app using
I'm trying to use the camera in an Android app using the 1.5 API.
I have an android app which uses camera. I am using a socket connection
I'm testing my app using HTC Wildfire with Android 2.2.1. The default camera preview
I am working on an Android app that I want to run on all

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.