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

The Archive Base Latest Questions

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

as the title says, I’m trying to scan 1D barcodes, so far I have

  • 0

as the title says, I’m trying to scan 1D barcodes, so far I have thet following code:

public class MainActivity extends Activity {

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

    public void test(View view){

        Intent intent = new Intent("com.google.zxing.client.android.SCAN");
        intent.putExtra("SCAN_MODE", "1D_CODE_MODE");
        startActivityForResult(intent, 0);
    }

    public void onActivityResult(int requestCode, int resultCode, Intent intent) {  
          switch (requestCode) {
          case IntentIntegrator.REQUEST_CODE:
             if (resultCode == Activity.RESULT_OK) {

                IntentResult intentResult = 
                   IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);

                if (intentResult != null) {

                   String contents = intentResult.getContents();
                   String format = intentResult.getFormatName();

                   TextView uno = (TextView) findViewById(R.id.textView1);
                   uno.setText(contents);
                   Toast.makeText(this, "Numero: " + contents, Toast.LENGTH_LONG).show();
                   Log.d("SEARCH_EAN", "OK, EAN: " + contents + ", FORMAT: " + format);
                } else {
                   Log.e("SEARCH_EAN", "IntentResult je NULL!");
                }
             } else if (resultCode == Activity.RESULT_CANCELED) {
                Log.e("SEARCH_EAN", "CANCEL");
             }
         }
    }   
}

And of course, I have both IntentResult and IntentIntegrator added to the project.

So, the scanner is beeing called correctly when a button is pressed and it seems to scan the code perfectly (it says “Text found” after it scans it), but it seems that the onActivityResult is not called, since the TextView is not beeing updated and the Toast is not appearing.

Any idea on what the mistake could be?

Thanks in advance!

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

    Your first mistake is not using IntentIntegrator.initiateScan(), replacing it with your own hand-rolled call to startActivityForResult().

    Your second mistake is in assuming that IntentIntegrator.REQUEST_CODE is 0. It is not.

    Hence, with your current code, you are sending out a request with request code of 0, which is coming back to onActivityResult() with request code of 0, which you are ignoring, because you are only looking for IntentIntegrator.REQUEST_CODE.

    Simply replace the body of your test() method with a call to initiateScan(), and you should be in better shape. Here is a sample project that demonstrates the use of IntentIntegrator.

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

Sidebar

Related Questions

As title says, mock code to demostrate my problem Driver Class import java.io.*; public
As the title says, I'm trying to do something like this: public abstract class
As the title says. For example: I have MainActivity and main.xml main.xml has WebView
Title says all. Sample code: ArrayList<HashMap<String, Object>> data = new ArrayList<HashMap<String, Object>>(); HashMap<String, Object>
As title says, I have a list of words, Like stopWords = [the, and,
As title says, I have access to the current listitem - and it's easy
The title says it mostly. If I have an object in Python and want
The title says enough I think. I have a full quality BufferedImage and I
Title says what i'm trying to do. I can successfully generate an assembly if
As title says, how do I call a java class method from a jsp,

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.