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

  • Home
  • SEARCH
  • 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 9183651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:51:28+00:00 2026-06-17T18:51:28+00:00

I am using the Android ADT Bundle for dev work. After reading multiple guides

  • 0

I am using the Android ADT Bundle for dev work. After reading multiple guides online I have added the package com.dm.zbar.android.scanner to my project. I have included the files CameraPreview.java, ZBarConstants.java, and ZBarScannerActivity.java in the package. Despite all this the ZBAR_SCANNER_REQUEST var in the class ScanActivity.java (created by me, but using zbar methods) cannot be resolved to a variable. Everything except this variable is accepted. Any idea why this is occurring? Note: My libs folder contains everything in here:

https://github.com/DushyanthMaguluru/ZBarScanner/tree/master/ZBarScannerLibrary/libs

and zbar.jar is included on the build path.

ScanActivity:

package com.xx.xxx;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.view.Menu;
import android.view.View;
import android.widget.Toast;
import com.dm.zbar.android.scanner.ZBarConstants;
import com.dm.zbar.android.scanner.ZBarScannerActivity;
import net.sourceforge.zbar.Symbol;

public class ScanActivity extends Activity {

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

public void launchScanner(View v) {
    if (isCameraAvailable()) {
        Intent intent = new Intent(this, ZBarScannerActivity.class);
        startActivityForResult(intent, ZBAR_SCANNER_REQUEST);
    } else {
        Toast.makeText(this, "Rear Facing Camera Unavailable", Toast.LENGTH_SHORT).show();
    }
}

public void launchQRScanner(View v) {
    if (isCameraAvailable()) {
        Intent intent = new Intent(this, ZBarScannerActivity.class);
        intent.putExtra(ZBarConstants.SCAN_MODES, new int[]{Symbol.QRCODE});
        startActivityForResult(intent, ZBAR_SCANNER_REQUEST);
    } else {
        Toast.makeText(this, "Rear Facing Camera Unavailable", Toast.LENGTH_SHORT).show();
    }
}

public boolean isCameraAvailable() {
    PackageManager pm = getPackageManager();
    return pm.hasSystemFeature(PackageManager.FEATURE_CAMERA);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
        case ZBAR_SCANNER_REQUEST:
        case ZBAR_QR_SCANNER_REQUEST:
            if (resultCode == RESULT_OK) {
                Toast.makeText(this, "Scan Result = " + data.getStringExtra(ZBarConstants.SCAN_RESULT), Toast.LENGTH_SHORT).show();
            }
            break;
    }
}

}

Just in case it is relevant:
AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xx.xxx"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="17" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />

<uses-feature
    android:name="android.hardware.camera"
    android:required="false" />

<application
    android:icon="@drawable/ic_launcher"
    android:label="xx"
    android:theme="@style/AppTheme" >
    <activity android:name="com.xx.xxx.MainActivity" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name="com.xx.xxx.WvActivity" />
    <activity android:name="com.xx.xxx.ScanActivity" />
    <activity
        android:name="com.dm.zbar.android.scanner.ZBarScannerActivity"
        android:screenOrientation="landscape" />
</application>

  • 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-17T18:51:29+00:00Added an answer on June 17, 2026 at 6:51 pm

    I checked the ZBar Library Example. You made a mistake.

    This error occurred because you did not declare these two variables in your activity

    private static final int ZBAR_SCANNER_REQUEST = 0;
    private static final int ZBAR_QR_SCANNER_REQUEST = 1;
    

    you need to declare these variables above your onCreate(..) Method.

    See the ZBar Example.

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

Sidebar

Related Questions

I am using Eclipse with ADT to develop apps for Android (ICS) and have
I'm trying to install ADT in Eclipse, using the instructions on developer.android.com, but I'm
I'm using Eclipse 3.5.2 and when I followed the steps on this tutorial( http://developer.android.com/guide/developing/tools/adt.html
I have created my first application for android Hello android. With using Eclipse, ADT
I am using android 2.1 platform.The code I have will display the Name number
I am using Android 2.1 platform, I have 7 contacts in my emulator when
I have just started using android, and have about 5 layout files finished. However,
I currently using android NDK to write some native code in C. I have
I recently started programming for Android using the Eclipse ADT. What I am frequently
I am trying to create the android emulator for Nexus 10 using latest ADT(21)

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.