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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:56:32+00:00 2026-05-23T11:56:32+00:00

I am looking to use Android’s Camera.open() method on two separate API levels. First

  • 0

I am looking to use Android’s Camera.open() method on two separate API levels. First is API level 7, which is 2.1 and higher and the second is 2.3.3 & 2.3.4 which are API level 9.

On API level 7 and 8 the Camera.open method does not take any arguments. On API level 9 and above, the camera takes an integer argument that supplies it the cameraId to use.

How can I target both API levels in the same code? Something similar to this pseudo code:

Camera lCamera;
if (Platform.APILevel < 7){
  lCamera.open();
}else { 
  lCamera.open(0);
}
  • 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-23T11:56:33+00:00Added an answer on May 23, 2026 at 11:56 am

    We often do reflection detection. Something like:

        public Camera getCamera() {
            try {
                Method method = Camera.class.getMethod("open", Integer.TYPE);
                return (Camera) method.invoke(null, 0);
            } catch (Exception e) {
                    // Yes, I really want to handle all exceptions here!!!!
                    Log.d(TAG,"Error when trying to invoke Camera.open(int), reverting to open()",e);
                    return Camera.open();
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am looking for android equivalent of UISwitch(iOS), which I could use to switch
I am looking to use quartz to schedule emails, but I'm not sure which
I am looking to use an IOC container in my current project which is
When you first use a name from the android XML namespace, you have to
I am developing a library for Android applications which does not use native code
I'm looking for a SIP stack to use on the Android platform. Since it's
I'm looking for a good ORM for my android application and at first glance
I am looking for a simple image sharpening algorithm to use in my Android
I am looking to build a button in my Android app which must contain:
Thats it. I am looking to use a C/C++ Library in my Android app.

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.