Friday, September 30, 2011

[android-developers] barcode scanner not launching

im having a little trouble with my app

i want the barcode scanner to open on the click of a button(scan1),
scan barcode, and return details to a edittext (barcode1).

here is what i have so far......


import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class Scanner extends Activity {

/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {

public Button.OnClickListener scan1 = new
Button.OnClickListener() {
public void onClick(View v) {
Intent intent = new
intent.putExtra("SCAN_MODE", "PRODUCT_MODE");
startActivityForResult(intent, 0);

public void onActivityResult(int requestCode, int resultCode,
Intent intent) {
if (requestCode == 0) {
if (resultCode == RESULT_OK) {
String contents =
// Handle successful scan
EditText editComment =
} else if (resultCode == RESULT_CANCELED) {
// Handle cancel


this is my manifest entry......

<activity android:name=".Scanner" android:label="@string/app_name" >
<action android:name=""/>
<category android:name="android.intent.category.DEFAULT"/>

any help would be great

many thanks

You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

No comments:

Post a Comment