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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:59:44+00:00 2026-06-17T09:59:44+00:00

My app has functionality that requires a rear camera. Whether there is a front

  • 0

My app has functionality that requires a rear camera. Whether there is a front camera or not is irrelevant to my needs. Putting together a robust routine to detect whether or not a rear camera exists, in all circumstances, is proving tricky. For example, a user with an HTC Evo 3D has complained that the app says there’s no rear camera (there clearly is), and I’ve had a number of similar complaints from other users.

This is a tricky thing to test, as despite having a number of devices I don’t have a device with only a front camera, such as the Nexus 7, or any of the models mentioned by the users.

Here’s what I have, and this was taken from code on other answers on this site:

boolean rearCameraFound = false;
    if(BUILD_VERSION > 8){
        int cameraCount = 0;
        Camera cam = null;
        Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
        cameraCount = Camera.getNumberOfCameras();
        for ( int camIdx = 0; camIdx < cameraCount; camIdx++ ) {
            Camera.getCameraInfo( camIdx, cameraInfo );
            if ( cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_BACK  ) {
                try {
                    cam = Camera.open( camIdx );
                    Log.d("TAG", "Rear camera detected");
                    rearCameraFound = true;
                } catch (RuntimeException e) {
                    Log.e("TAG", "Camera failed to open: " + e.getLocalizedMessage());
                }
            }
            if ( cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT ) {
                Log.d("TAG", "Front camera detected");
            }
        }
        return rearCameraFound;
    }else{
        if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA)){
            // this device has a camera
            return true;
        } else {
            // no camera on this device
            return false;
        }
    }

I’ve now replaced this code with this much simpler version:

PackageManager pm = context.getPackageManager();
return pm.hasSystemFeature(PackageManager.FEATURE_CAMERA);

However, I don’t know what would happen on the Nexus 7 for example, with only a front camera. Would this return true?

I’m looking for code that will tell me for sure if there’s a rear camera or not!

  • 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-17T09:59:45+00:00Added an answer on June 17, 2026 at 9:59 am

    Nexus 7 (which has only one frontal camera) returns false to FEATURE_CAMERA, Instead of it, you can use FEATURE_CAMERA_FRONT. Check out this discussion.

    Now, by using the above, you could make sure that there is atleast one camera. So now, you can check the number of camera’s present in the phone, if it is greater than one, then there will be surely a rear camera.

    import android.hardware.Camera;
    
    int numCameras = Camera.getNumberOfCameras();
    if (numCameras > 1) {
      rearCamera = true;
    }
    

    This is quite tricky. But that’s all, I can now think of. Just give it a try.

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

Sidebar

Related Questions

I am building a FB canvas app that has share functionality, my plan is
I'm currently doing the calculator app that has the graph functionality. So then, I
I'm building a Rails app that has Etsy.com style functionality. In other words, it's
I'm currently coding an app that has hotkey functionality, I've done some reading and
The app I'm writing requires camera functionality. So to learn about how to operate
I'm writing a social networking app that has contacts sync functionality. I have working
I'm creating an app that needs to be accessed by both a web front
My app has an options menu that is available in almost all Activities, which
I’m creating an Android app that requires access to device drivers of Broadcomm’s Single
The iPhone has a functionality that when a google maps URL is typed into

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.