我有一个应用程序需要扫描条形码才能获得代码才能继续.
我使用此代码开始扫描活动:
finish = (Button) findViewById(R.id.finishButton);
finish.setOnClickListener(new OnClickListener() {
public void onClick(View viewParam) {
/*Prompt the user to scan the barcode */
new AlertDialog.Builder(Visit.this)
.setMessage("Please Scan the clients barcode to complete the visit")
.setPositiveButton("Scan Barcode", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//Start the scan application
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
startActivityForResult(intent, 0);
}
})
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//Execute some method call
Toast.makeText(Visit.this, "Scan declined...", Toast.LENGTH_SHORT).show();
} …Run Code Online (Sandbox Code Playgroud)