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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:04:36+00:00 2026-06-10T09:04:36+00:00

I am absolute begginer in android devlopment and i want to make a camera

  • 0

I am absolute begginer in android devlopment and i want to make a camera On/Off application but i get error. so please help me.

package com.vikram.flashcamera;

import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager;
import android.hardware.Camera;
import android.hardware.Camera.Parameters;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MainActivity extends Activity {
    private boolean isLighOn = false;
    private Camera camera;
    private Button button;

    @Override
    protected void onStop() {
        super.onStop();

        if(camera != null) {
            camera.release();
        }
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        button = (Button) findViewById(R.id.buttonClick);

        Context context = this;
        PackageManager pm = context.getPackageManager();

        if(!pm.hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
            Log.e("err", "Device has no camera!");
            return;
        }

        camera = Camera.open();
        final Parameters p = camera.getParameters();

        button.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {
                if(isLighOn) {
                    Log.i("info", "torch is turn off!");
                    p.setFlashMode(Parameters.FLASH_MODE_OFF);
                    camera.setParameters(p);
                    camera.stopPreview();
                    isLighOn = false;
                }
                else {
                   Log.i("info", "torch is turn on!");
                    p.setFlashMode(Parameters.FLASH_MODE_TORCH);

                    camera.setParameters(p);
                    camera.startPreview();
                    isLighOn = true;
                }
            }
        });
    }
}

and my logCat error is given below.

    08-25 15:50:41.932: E/Trace(878): error opening trace file: No such file or directory (2)
    08- 5 15:50:42.453: D/AndroidRuntime(878): Shutting down VM
    08-25 15:50:42.463: W/dalvikvm(878): threadid=1: thread exiting with uncaught exception     (group=0x40a13300)
    08-25 15:50:42.473: E/AndroidRuntime(878): FATAL EXCEPTION: main
    08-25 15:50:42.473: E/AndroidRuntime(878): java.lang.RuntimeException: Unable to start     activity         ComponentInfo{com.vikram.flashcamera/com.vikram.flashcamera.MainActivity}:     java.lang.NullPointerException
    08-25 15:50:42.473: E/AndroidRuntime(878):  at     android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
    08-25 15:50:42.473: E/AndroidRuntime(878):  at     android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
08-25 15:50:42.473: E/AndroidRuntime(878):  at         android.app.ActivityThread.access$600(ActivityThread.java:130)
08-25 15:50:42.473: E/AndroidRuntime(878):  at         android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
    08-25 15:50:42.473: E/AndroidRuntime(878):  at android.os.Handler.dispatchMessage(Handler.java:99)
    08-25 15:50:42.473: E/AndroidRuntime(878):  at android.os.Looper.loop(Looper.java:137)
    08-25 15:50:42.473: E/AndroidRuntime(878):  at android.app.ActivityThread.main(ActivityThread.java:4745)
    08-25 15:50:42.473: E/AndroidRuntime(878):  at java.lang.reflect.Method.invokeNative(Native Method)
    08-25 15:50:42.473: E/AndroidRuntime(878):  at java.lang.reflect.Method.invoke(Method.java:511)
    08-25 15:50:42.473: E/AndroidRuntime(878):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
    08-25 15:50:42.473: E/AndroidRuntime(878):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
    08-25 15:50:42.473: E/AndroidRuntime(878):  at dalvik.system.NativeStart.main(Native Method)
    08-25 15:50:42.473: E/AndroidRuntime(878): Caused by: java.lang.NullPointerException
    08-25 15:50:42.473: E/AndroidRuntime(878):  at com.vikram.flashcamera.MainActivity.onCreate(MainActivity.java:44)
    08-25 15:50:42.473: E/AndroidRuntime(878):  at android.app.Activity.performCreate(Activity.java:5008)
    08-25 15:50:42.473: E/AndroidRuntime(878):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
    08-25 15:50:42.473: E/AndroidRuntime(878):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
    08-25 15:50:42.473: E/AndroidRuntime(878):  ... 11 more
    08-25 18:03:08.543: E/Trace(900): error opening trace file: No such file or directory (2)
    08-25 18:03:09.122: D/AndroidRuntime(900): Shutting down VM
    08-25 18:03:09.122: W/dalvikvm(900): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
    08-25 18:03:09.132: E/AndroidRuntime(900): FATAL EXCEPTION: main
    08-25 18:03:09.132: E/AndroidRuntime(900): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.vikram.flashcamera/com.vikram.flashcamera.MainActivity}:     java.lang.NullPointerException
    08-25 18:03:09.132: E/AndroidRuntime(900):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
    08-25 18:03:09.132: E/AndroidRuntime(900):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
    08-25 18:03:09.132: E/AndroidRuntime(900):  at android.app.ActivityThread.access$600(ActivityThread.java:130)
    08-25 18:03:09.132: E/AndroidRuntime(900):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
    08-25 18:03:09.132: E/AndroidRuntime(900):  at android.os.Handler.dispatchMessage(Handler.java:99)
    08-25 18:03:09.132: E/AndroidRuntime(900):  at android.os.Looper.loop(Looper.java:137)
    08-25 18:03:09.132: E/AndroidRuntime(900):  at android.app.ActivityThread.main(ActivityThread.java:4745)
    08-25 18:03:09.132: E/AndroidRuntime(900):  at java.lang.reflect.Method.invokeNative(Native Method)
    08-25 18:03:09.132: E/AndroidRuntime(900):  at java.lang.reflect.Method.invoke(Method.java:511)
    08-25 18:03:09.132: E/AndroidRuntime(900):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
    08-25 18:03:09.132: E/AndroidRuntime(900):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
    08-25 18:03:09.132: E/AndroidRuntime(900):  at dalvik.system.NativeStart.main(Native Method)
    08-25 18:03:09.132: E/AndroidRuntime(900): Caused by: java.lang.NullPointerException
    08-25 18:03:09.132: E/AndroidRuntime(900):  at com.vikram.flashcamera.MainActivity.onCreate(MainActivity.java:44)
    08-25 18:03:09.132: E/AndroidRuntime(900):  at android.app.Activity.performCreate(Activity.java:5008)
    08-25 18:03:09.132: E/AndroidRuntime(900):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
    08-25 18:03:09.132: E/AndroidRuntime(900):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
    08-25 18:03:09.132: E/AndroidRuntime(900):  ... 11 more
    08-25 18:03:11.613: I/Process(900): Sending signal. PID: 900 SIG: 9
    08-25 18:33:52.222: E/Trace(929): error opening trace file: No such file or directory    (2)
    08-25 18:33:52.813: D/AndroidRuntime(929): Shutting down VM
    08-25 18:33:52.813: W/dalvikvm(929): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
    08-25 18:33:52.833: E/AndroidRuntime(929): FATAL EXCEPTION: main
    08-25 18:33:52.833: E/AndroidRuntime(929): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.vikram.flashcamera/com.vikram.flashcamera.MainActivity}: java.lang.NullPointerException
    08-25 18:33:52.833: E/AndroidRuntime(929):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
    08-25 18:33:52.833: E/AndroidRuntime(929):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
    08-25 18:33:52.833: E/AndroidRuntime(929):  at android.app.ActivityThread.access$600(ActivityThread.java:130)
    08-25 18:33:52.833: E/AndroidRuntime(929):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
    08-25 18:33:52.833: E/AndroidRuntime(929):  at android.os.Handler.dispatchMessage(Handler.java:99)
    08-25 18:33:52.833: E/AndroidRuntime(929):  at android.os.Looper.loop(Looper.java:137)
    08-25 18:33:52.833: E/AndroidRuntime(929):  at android.app.ActivityThread.main(ActivityThread.java:4745)
    08-25 18:33:52.833: E/AndroidRuntime(929):  at java.lang.reflect.Method.invokeNative(Native Method)
    08-25 18:33:52.833: E/AndroidRuntime(929):  at java.lang.reflect.Method.invoke(Method.java:511)
    08-25 18:33:52.833: E/AndroidRuntime(929):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
    08-25 18:33:52.833: E/AndroidRuntime(929):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
    08-25 18:33:52.833: E/AndroidRuntime(929):  at dalvik.system.NativeStart.main(Native Method)
    08-25 18:33:52.833: E/AndroidRuntime(929): Caused by: java.lang.NullPointerException
    08-25 18:33:52.833: E/AndroidRuntime(929):  at com.vikram.flashcamera.MainActivity.onCreate(MainActivity.java:44)
    08-25 18:33:52.833: E/AndroidRuntime(929):  at android.app.Activity.performCreate(Activity.java:5008)
    08-25 18:33:52.833: E/AndroidRuntime(929):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
    08-25 18:33:52.833: E/AndroidRuntime(929):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
    08-25 18:33:52.833: E/AndroidRuntime(929):  ... 11 more
    08-25 18:38:52.904: I/Process(929): Sending signal. PID: 929 SIG: 9
  • 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-10T09:04:38+00:00Added an answer on June 10, 2026 at 9:04 am

    As your AVD is not getting the camera I think this may help you:
    Enable Camera in AVD

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

Sidebar

Related Questions

I'm an absolute beginner at Android programming, so please bear with me :) For
Given an absolute URI/URL, I want to get a URI/URL which doesn't contain the
Absolute newbie question, any help is highly appreciated :) I am using curvycorners (
I'm almost an absolute beginner in Python, but I am asked to manage some
I'm an absolute noob at iPhone development but I know a little C. I
Is absolute absolute or not? I am trying to make an input form with
Possible Duplicate: Absolute path & Relative Path This is a very basic question, but
I have an absolute positioned jQuery slider on my page. With it, I want
absolute newbie in this space so please adjust :-) this has to work on
I'm an absolute beginner in Outlook programming and Windows GUI programming in general. But

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.