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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:43:20+00:00 2026-06-08T00:43:20+00:00

Okay, So I am developing an in house barcode scanner for my company to

  • 0

Okay, So I am developing an in house barcode scanner for my company to use when we move computers and equipment. I am currently almost through setting up the Zxing Barcode Scanner Via Intent after some trial and error.

Here is what I’m trying to do.

Next to three EditText fields I have Three ImageButtons that when clicked, implement the BarcodeScanner, once scanned returns the value and inputs the value into the EditText field. I was able to do it successfully using one “listener” corresponding to one ImageButton. But after trying to use multiple Buttons with one listener, it calls the barcode scanner but crashes when trying to return the barcode value.

The Debugger shows the main Thread Suspended and I have to resume the debugger twice before the RuntimeException error appears in Logcat.

here’s the error log from LogCat:

07-17 17:38:49.251: E/AndroidRuntime(30942):
java.lang.RuntimeException: Unable to resume activity
{com.fmi.inventory/com.fmi.inventory.MainActivity}:
java.lang.RuntimeException: Failure delivering result
ResultInfo{who=null, request=49374, result=-1, data=Intent {
act=com.google.zxing.client.android.SCAN flg=0x80000 (has extras) }}
to activity {com.fmi.inventory/com.fmi.inventory.MainActivity}:
java.lang.NullPointerException

Here is my MainActivity:

package com.fmi.inventory;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageButton;

public class MainActivity extends Activity {

    ImageButton button;
    ImageButton button1;
    ImageButton button2;
    EditText editField;
    Activity activity;

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

        activity = this;
        button = (ImageButton)findViewById(R.id.scanCubeID);
        button1 = (ImageButton)findViewById(R.id.scanEmployeeID);
        button2 = (ImageButton)findViewById(R.id.scanConfigID);
        button.setOnClickListener(listener);
        button1.setOnClickListener(listener);
        button2.setOnClickListener(listener);

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }

    @Override
    public void onResume() {
        super.onResume();

    }

    public void setCubeClick(){
        editField = (EditText)findViewById(R.id.editCubeID);
    }

    public void setEmployeeClick(){
        editField = (EditText)findViewById(R.id.editEmployeeID);
    }

    public void setConfigClick(){
        editField = (EditText)findViewById(R.id.editConfigID);
    }

    private View.OnClickListener listener = new View.OnClickListener() {
        public void onClick(View v) {
            IntentIntegrator integrator = new IntentIntegrator(activity);
            integrator.initiateScan();

        }
    };

    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();
                    this.editField.setText(contents);
                    // this.elemQuery.setText(contents);
                    //this.resume = false;
                    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");
            }
        }
    }
}

Here is my layout .xml for MainActivity

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <EditText
        android:id="@+id/editCubeID"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/scanEmployeeID"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_toLeftOf="@+id/scanCubeID"
        android:ems="10"
        android:hint="@string/edit_cubeid" >

        <requestFocus />
    </EditText>

    <EditText
        android:id="@+id/editEmployeeID"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/scanConfigID"
        android:layout_alignParentLeft="true"
        android:layout_alignRight="@+id/editCubeID"
        android:layout_below="@+id/editCubeID"
        android:ems="10"
        android:hint="@string/edit_employeeid" />

    <EditText
        android:id="@+id/editConfigID"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/scanConfigID"
        android:layout_alignParentLeft="true"
        android:layout_alignRight="@+id/editEmployeeID"
        android:layout_below="@+id/editEmployeeID"
        android:ems="10"
        android:hint="@string/edit_configid" />

    <ImageButton
        android:id="@+id/scanCubeID"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:contentDescription="@string/desc"
        android:layout_alignParentTop="true"
        android:src="@drawable/ic_action_scan"
        android:onClick="onClick" />

    <ImageButton
        android:id="@+id/scanEmployeeID"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:contentDescription="@string/desc"
        android:layout_below="@+id/scanCubeID"
        android:src="@drawable/ic_action_scan"
        android:onClick="onClick" />

    <ImageButton
        android:id="@+id/scanConfigID"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:contentDescription="@string/desc"
        android:layout_below="@+id/scanEmployeeID"
        android:src="@drawable/ic_action_scan"
        android:onClick="onClick" />

    <Button
        android:id="@+id/submit"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/editConfigID"
        android:text="@string/button_continue" />

</RelativeLayout>
  • 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-08T00:43:23+00:00Added an answer on June 8, 2026 at 12:43 am

    When your Activity come in onActivityResult after scanning.You are accessing editField but it is NULL.

    as you never Initialized it..

    You are Initializing them in setCubeClick, setEmployeeClick or setConfigClick,

    But I am affraid they never called..Try to Initialize them in OnCreat

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

Sidebar

Related Questions

Okay, so I'm currently developing an iphone app that I plan to take into
Okay, so I'm developing an application that will allow users to select file objects
I'm developing a small custom scrollbar plugin. Everything is okay, but how do I
Is it okay to update ADT plugin to latest release ADT-17 preview, while developing
Okay basically, I'm designing and developing a fairly complicated website which revolves around the
Okay, here's the rundown. I'm developing a video hosting site with PHP and jQuery
Okay, I am developing an Application which requires getting sensitive information from a database
Okay, allow me to say first off that I am working on developing my
Okay, so I have been developing in Java for a little over a year
I'm developing a SIP provider application.I use transport UDP.And I have a Questions, I

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.