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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:00:25+00:00 2026-06-14T21:00:25+00:00

In Android 2.3 application I used to support two cameras: one built-in and onу

  • 0

In Android 2.3 application I used to support two cameras: one built-in and onу externally MJPG-streamed using Wi-Fi. The built-in camera must be recording video all the time and a user must have the ability to switch view between those. So, each camera had a dedicated SurfaceView to draw on. As the last child added to a FrameLayout has a higher Z-order, I programatically add the required camera view to a FrameLayout last to make it visible. I can’t skip adding built-in camera since it can’t record video without the preview display.

This scheme no longer works with Android 4: the built-in camera preview is always shown in spite of being added first or last. I played with ‘setVisibility’ methods on views and noticed that if one of views is set to be invisible (or gone) then none of them is showed at all. ViewGroup’s ‘bringChildToFront’ method had no effect as well.

So, is there some workaround to make this work on Android 4? And I know that having multiple SurfaceViews is considered bad. Some code follows.

FrameLayout:

<FrameLayout android:id="@id/data"
             android:layout_width="fill_parent" android:layout_height="fill_parent"/>

Code that populates the layout (no longer works on Android 4):

private void setCorrectView() {
    data.removeAllViews();

    List<Recorder> others = recorders.getOthers();
    for (Recorder other : others) {
        addToTheView(other);
    }

    addToTheView(recorders.getCurrent());
}

private void addToTheView(Recorder recorder) {
    View view = recorder.getView(this); // get recorder's surface view
    data.addView(view);
}

The same effect if I use FrameLayouts from XML:

<FrameLayout android:layout_width="fill_parent" android:layout_height="fill_parent"
         xmlns:android="http://schemas.android.com/apk/res/android">

    <FrameLayout
        android:id="@id/data"
        android:layout_width="fill_parent" android:layout_height="fill_parent"/>

    <FrameLayout
        android:id="@+id/data_invisible"
        android:layout_width="fill_parent" android:layout_height="fill_parent"/>

</FrameLayout>

Wherever I put built-in camera’s surface view – it’s always shown. Looks like internal camera’s preview is now always on top in Android 4.

  • 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-14T21:00:28+00:00Added an answer on June 14, 2026 at 9:00 pm

    Answering to myself. To make this work I set the views’ visibility to View.VISIBLE before starting the camera and set it to View.INVISIBLE after. This link may be helpful.

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

Sidebar

Related Questions

I have built an Android application using PhoneGap and for tweeting I have used
I am working in android chat application. I used SmartFox server. I am using
I have used facebook application for one of my android application. But i need
I used this code in my Android application: import org.apache.http.client.methods.HttpPost; ... HttpClient httpclient =
I am working on an android application which can be used to capture the
I would like some help about an Android Application. I used the new Google
I want to create a android search application that can be used to search
to send a message in my application in android i have used the following
I have a ASP.NET Webforms application that is being used with Motorola Tablets (Android
I'm writing an API on Android that will be used by an existing application,

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.