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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:25:27+00:00 2026-06-05T22:25:27+00:00

My app uses Barcode Scanner. I want to launch the scanner when I open

  • 0

My app uses Barcode Scanner. I want to launch the scanner when I open the app so I have it in the onCreate method. The problem is that if I have it like that, when I turn the device it calls again onCreate and calls another scanner.

Also I have the first activity that calls the scanner. it has a menu so if the user presses back, it goes to that menu. If I turn the screen on that menu, it goes to barcode scanner again.

To solve it I have a flag that indicates if it is the first time I call the scanner, if it’s not I don’t call it again. Now the problem is that if I go out of the app and go in again it doesn’t go to the scanner, it goes to the menu, becasuse is not the first time I call it.

Any ideas? Is there a way to change the flag when I go out of my main activity or any other solution? My code.

private static boolean first = true;
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    integrator = new IntentIntegrator(this);
    if (first) {
        first = false;
        integrator.initiateScan();
    }

}
  • 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-05T22:25:28+00:00Added an answer on June 5, 2026 at 10:25 pm

    In your Application manifest.xml, add this to your Activity where this barcode scanner is called

    android:configChanges="orientation"
    

    like this

    <activity
    android:name=".YourActivity"
    android:configChanges="orientation"
    android:label="@string/app_name" />
    

    what it does is, when the device is rotated, it will “do nothing” which mean it will not call the activity again (which eventually avoids calling onCreate())

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

Sidebar

Related Questions

My WinForms app uses Process.Start() to open files in their native app. I want
we have an APP, that uses many local resources, such as windows printing API,
My app uses Mochiweb. I have noticed that Mochiweb files reside in the myapp/deps/mochiweb
My app uses GPS. At first launch, user is asked if he want's to
My Java app uses a java.util.concurrent.Executors.newCachedThreadPool() to launch a number of different threads that
My app uses a method that was deprecated since Android 2.1 with a different
My iPad app uses an external device that acts as a hardware keyboard. But,
I have an app that uses the Zbar SDK I have everything up and
I am developing an app which uses barcode to get the product information of
Our app uses a component that requires a license file in the directory with

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.