Friday, September 30, 2011

Re: [android-developers] barcode scanner not launching

I suggest using their IntentIntegrator, as I did in this somewhat-old
sample project:

https://github.com/commonsguy/zxingdemo

Also, delete your <intent-filter> -- *you* are not *implementing* an
activity supporting com.google.zxing.client.android.SCAN. You are
*consuming* an activity from the Barcode Scanner application that
implements com.google.zxing.client.android.SCAN.

Beyond that, since you did not state what your problem is, it may be
difficult for people to assist you.

On Fri, Sep 30, 2011 at 7:30 PM, leigh8347 <leigh8347@aol.com> wrote:
> 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......
>
> package com.android.app;
>
> import android.app.Activity;
> 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. */
>            @Override
>            public void onCreate(Bundle savedInstanceState) {
>                super.onCreate(savedInstanceState);
>                setContentView(R.layout.scanner);}
>
>            public Button.OnClickListener scan1 = new
> Button.OnClickListener() {
>                public void onClick(View v) {
>                    Intent intent = new
> Intent("com.google.zxing.client.android.SCAN");
>                    intent.setPackage("com.google.zxing.client.android");
>                    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 =
> intent.getStringExtra("SCAN_RESULT");
>                        // Handle successful scan
>                        EditText editComment =
> (EditText)findViewById(R.id.barcode1);
>                                editComment.setText(contents);
>                    } else if (resultCode == RESULT_CANCELED) {
>                        // Handle cancel
>                    }
>                }
>            }
>
> }
>
>
> this is my manifest entry......
>
>                <activity android:name=".Scanner" android:label="@string/app_name" >
>                        <intent-filter>
>        <action android:name="com.google.zxing.client.android.SCAN"/>
>        <category android:name="android.intent.category.DEFAULT"/>
>      </intent-filter>
>                </activity>
>
>
> 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 android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscribe@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_The Busy Coder's Guide to *Advanced* Android Development_ Version 2.0
Available!

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment