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

  • SEARCH
  • Home
  • 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 8996735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:47:40+00:00 2026-06-15T23:47:40+00:00

when I run my android camera application in the computer, web camera is not

  • 0

when I run my android camera application in the computer, web camera is not working.

here the code. Manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.examples"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="8" />

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

<uses-permission android:name="android.permission.CAMERA" />
</manifest>

main.xml

 <?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:orientation="vertical" >
   <FrameLayout
    android:layout_weight="1"
  android:layout_width="fill_parent"
   android:layout_height="fill_parent">

 <SurfaceView
 android:id="@+id/surfaceView1"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 /> 

 </FrameLayout>
    <LinearLayout
   android:layout_width="fill_parent"
      android:layout_height="wrap_content"
  android:orientation="horizontal"
 android:layout_marginTop="300px"
 android:paddingLeft="5px"
 android:paddingTop="5px"
 android:paddingRight="5px">    

 <ImageButton
     android:layout_width="50px"
     android:textColor="#ffffff"
     android:layout_height="50px"
     android:id="@+id/cameraClick "
      />

   </LinearLayout> 

   </RelativeLayout>

java file

 package com.examples;

 import java.io.IOException;
 import android.app.Activity;
 import android.hardware.Camera;
 import android.hardware.Camera.PictureCallback;
 import android.hardware.Camera.ShutterCallback;
 import android.os.Bundle;
 import android.view.SurfaceHolder;
 import android.view.SurfaceView;
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.widget.ImageButton;

 public class MainActivity extends Activity implements SurfaceHolder.Callback{

      private Camera camera;
  private ImageButton cameraClick;
  private SurfaceHolder mHolder; 

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

   SurfaceView surfaceView = (SurfaceView)findViewById(R.id.surfaceView1);
   mHolder = surfaceView.getHolder();
   mHolder.addCallback(this);
   mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);  

   cameraClick = (ImageButton) findViewById(R.id.cameraClick);
   cameraClick.setOnClickListener( new OnClickListener() {
    public void onClick(View v)
              {
 camera.takePicture(shutterCallback, rawCallback,jpegCallback);
    }
   });  

   }

  // Handles when shutter open
  ShutterCallback shutterCallback = new ShutterCallback()
  {
   public void onShutter()
   {   

   }
  };

  /** Handles data for raw picture */
  PictureCallback rawCallback = new PictureCallback()
  {
   public void onPictureTaken(byte[] data, Camera camera)
   {   

   }
  }; 

  /** Handles data for jpeg picture */
  PictureCallback jpegCallback = new PictureCallback()
 {
   public void onPictureTaken(byte[] data, Camera camera)
 {
    // we do something using return byte[] of taken image.
   }
  };

  @Override
  public void surfaceChanged(SurfaceHolder holder,int format,int width,int height)
 {

   // Set camera preview size,orientation,rotation using parameters 

 Camera.Parameters parameters = camera.getParameters();
    parameters.set("orientation", "portrait");
    camera.setParameters(parameters);
     camera.startPreview();       

  }

  @Override
  public void surfaceCreated(SurfaceHolder holder)
 {
   camera = Camera.open();
     try {
     camera.setPreviewDisplay(holder);
    }
 catch (IOException e)
 {
     e.printStackTrace();
    }

  }

  @Override
  public void surfaceDestroyed(SurfaceHolder holder)
 {
   camera.stopPreview();
     camera.release();
    camera = null; 

  }

 }

when I run this code, web camera can’t start. kindly help me to resolve this problem. thanks

  • 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-06-15T23:47:41+00:00Added an answer on June 15, 2026 at 11:47 pm

    I am sorry about this question. Computer web camera haven’t integrated with the Android Emulator. When I do this code, I am just new to the Android. so I didn’t know about this simple thing.

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

Sidebar

Related Questions

I was have written to run simple android camera application to run it on
I'm developing an Android application that uses the camera and will run on Android
I have a Java handler code which Im using in android to run a
i'm new to android i've created one camera app from scratch in here i
I have a question this time around regarding the Android custom camera, NOT the
I'm doing a camera application, using the code I found on the internet, that
In my app, I was able to run a code using the camera class
I am working on an Android app that I want to run on all
I'm working on an app which is designed to run on any android device
I am trying to save a picture in an Android application. Here is my

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.