KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am trying to use Zxing Library for developing a barcode scanner. My activity is as follows: public class Scanner extends Activity { private static final String PACKAGE = "com.test.scan"; private static final String SCANNER = "com.google.zxing.client.android.SCAN"; private static final String SCAN_FORMATS = "UPC_A,UPC_E,EAN_8,EAN_13,CODE_39,CODE_93,CODE_128"; private static final String SCAN_MODE = "QR_CODE_MODE"; public static final int REQUEST_CODE = 1; @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); Button ok; ok = (Button) findViewById(R.id.b1); ok.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent scanIntent = new Intent(SCANNER); scanIntent.setPackage(PACKAGE); scanIntent.addCategory(Intent.CATEGORY_DEFAULT); scanIntent.putExtra("SCAN_FORMATS", SCAN_FORMATS); scanIntent.putExtra("SCAN_MODE", SCAN_MODE); try { startActivityForResult(scanIntent, REQUEST_CODE); } catch (ActivityNotFoundException e) { // TODO: Exception handling } } }); } Also manifest file: <activity android:name=".Scanner" android:screenOrientation="landscape" android:configChanges="orientation|keyboardHidden" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:windowSoftInputMode="stateAlwaysHidden"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>
Tags (comma-separated)
Save Edits
Cancel