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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:30:55+00:00 2026-05-20T16:30:55+00:00

I have a project running on where i call the ZXing scanner on button

  • 0

I have a project running on where i call the ZXing scanner on button push, after scanning the bardcode another activity comes up where it shows the scanned data and i can put in an amount. Then i got 2 buttons finish, which will go back to the main window , and the next button which closes this activity and calls ZXing again, after scanning the code the window (should) come up again where i can put in the amount so on .. so on… but after the first next button push the amount input window wont come up and it puts me back to the main window. I got the 2 activity codes here.

This is my main activity where i call the ZXing the first time on button push.
package org.example.sudoku;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.content.Intent;
import android.app.AlertDialog;
import com.google.zxing.integration.android.IntentIntegrator;
import com.google.zxing.integration.android.IntentResult;

public class Sudoku extends Activity implements OnClickListener {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
     // Set up click listeners for all the buttons

        View exitButton = findViewById(R.id.exit_button);
        exitButton.setOnClickListener(this);
        View scanButton = findViewById(R.id.scan_button);
        scanButton.setOnClickListener(this);
        View editButton = findViewById(R.id.about_button);
        editButton.setOnClickListener(this);

    }
    public void onClick(View v) {
        switch (v.getId()) {
        case R.id.scan_button:
            Intent intent = new Intent("com.google.zxing.client.android.SCAN");
            intent.putExtra("com.google.zxing.client.android.SCAN.SCAN_MODE", "ONE_D_MODE");
            startActivityForResult(intent, 0);
        break;
        case R.id.about_button:
            Intent about = new Intent(this.getApplicationContext(),About.class);
            Bundle b = new Bundle();

            b.putString("key","blablabla");


            about.putExtras(b);
            startActivityForResult(about, 0);
        break;
        case R.id.exit_button:
            finish();
        break;


                    }
                }



    public void onActivityResult(int requestCode, int resultCode, Intent intent) {
        if (requestCode == 0) {
            if (resultCode == RESULT_OK) {
                String contents = intent.getStringExtra("SCAN_RESULT");
                //String format = intent.getStringExtra("SCAN_RESULT_FORMAT");

                // Handle successful scan
                Intent result = new Intent(this.getApplicationContext(),Result.class);
                Bundle b = new Bundle();
                b.putString("content",contents);
                result.putExtras(b);
                startActivityForResult(result, 0);



            } else if (resultCode == RESULT_CANCELED) {
                // Handle cancel
            }
        }
    }
    /*protected void onActivityResult(int requestCode, int resultCode,Intent data) {
                switch(requestCode) {
                    case IntentIntegrator.REQUEST_CODE: {
                        if (resultCode != RESULT_CANCELED) {
                            IntentResult scanResult =IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
                            if (scanResult != null) {
                                String upc = scanResult.getContents();
                                Intent result = new Intent(this.getApplicationContext(),Result.class);

                                Bundle b = new Bundle();
                                b.putString("content",upc);
                                result.putExtras(b);
                                startActivityForResult(result, 0);
                            }
                        }
                        break;
                    }
                }
    }*/
}

And this is my upcoming activity after the scan is done.

package org.example.sudoku;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.*;
import android.content.Intent;

public class Result extends Activity implements OnClickListener {
        @Override
        protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.result);

        Bundle b = getIntent().getExtras();
        String product = b.getString("content").toString(); 
        TextView et1 = (TextView) findViewById(R.id.edit_text);         
        et1.setText(product);

        View finishButton =findViewById(R.id.finish_button);
        finishButton.setOnClickListener(this);
        View nextButton =findViewById(R.id.next_button);
        nextButton.setOnClickListener(this);


        }
        public void onClick(View v) {
            switch (v.getId()) {

            case R.id.finish_button:
                finish();
            break;
            case R.id.next_button:
                Intent intent2 = new Intent("com.google.zxing.client.android.SCAN");
                intent2.putExtra("com.google.zxing.client.android.SCAN.SCAN_MODE", "ONE_D_MODE");
                startActivityForResult(intent2, 0);
                finish();
            break;

            }
        }
        public void onActivityResult(int requestCode, int resultCode, Intent intent) {
            if (requestCode == 0) {
                if (resultCode == RESULT_OK) {
                    String contents = intent.getStringExtra("SCAN_RESULT");
                    String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
                    // Handle successful scan
                    Intent result = new Intent(this.getApplicationContext(),Result.class);
                    Bundle b = new Bundle();
                    b.putString("content",contents);
                    result.putExtras(b);
                    startActivityForResult(result, 0);

                } else if (resultCode == RESULT_CANCELED) {
                    // Handle cancel
                }
            }
        }




}

On this activity are the 2 buttons , finish and next, the finish button works fine it closes the activity well, but the next button is the problem it calls the ZXing , but after the scan it puts me back to the main activity. But if i dont call the finish() on this button the after im done with like 10 scans i have to close all the activitys.

I could need a bit help here. Thanks in front.

  • 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-20T16:30:55+00:00Added an answer on May 20, 2026 at 4:30 pm

    In your Result class, shouldn’t you remove finish()?

    case R.id.next_button:
                Intent intent2 = new Intent("com.google.zxing.client.android.SCAN");
                intent2.putExtra("com.google.zxing.client.android.SCAN.SCAN_MODE", "ONE_D_MODE");
                startActivityForResult(intent2, 0);
                finish(); // REMOVE THIS
            break;
    

    As you are starting the activity, expecting a result, but the activity has finished?

    If you dont finish it the class will receive the result and start another result class and THEN you should finish

    public void onActivityResult(int requestCode, int resultCode, Intent intent) {
            if (requestCode == 0) {
                if (resultCode == RESULT_OK) {
                    String contents = intent.getStringExtra("SCAN_RESULT");
                    String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
                    // Handle successful scan
                    Intent result = new Intent(this.getApplicationContext(),Result.class);
                    Bundle b = new Bundle();
                    b.putString("content",contents);
                    result.putExtras(b);
                    startActivityForResult(result, 0);
                    finish(); // NEW FINISH
                } else if (resultCode == RESULT_CANCELED) {
                    // Handle cancel
                }
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have project in Dropbox and two running laptops: one with Ubuntu and one
I have a MVC3 project for running on the iPad in the web-app mode.
I have several instances of my project running on my server, like so: http://0.0.0.0/one
I am creating a small commercial web project running Apache/WSGI/Django/MySQL. I have a development
I have a project in Java I am running that uses an external JAR
I have a Django-project which was running fine, until I made some changes I
I have a project where I have multiple instances of an app running, each
Now we have a project with java 1.4 and ejb 2.1 running on jboss
I'm currently writing a ToDo-Script for a project i have running. Now there is
I have a TabActivity implemented for my project which is running fine up to

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.