Star
Star

Reputation: 707

How to find scanned image is QR or Barcode?

Hi How to get scanned image is barcode or QR? Here is my code where I can get only product id but i couldn't get scanned format name. How to solve this. Please me to solve this.

  import android.content.Intent;
  import android.graphics.Bitmap;
  import android.os.Bundle;
   import com.contus.sportscorner.utils.Constants;
  import com.google.zxing.Result;
 import com.google.zxing.client.android.CaptureActivity;

public class ScannerActivity extends CaptureActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.barcode_scan);
}

 @Override
 public void handleDecode(Result rawResult, Bitmap barcode) {
    String productId = rawResult.getText();
    Intent intent = new Intent(ScannerActivity.this, NextAcitivity.class);
    intent.putExtra(Constants.ID, productId); // i am getting just product
                                                // id
    startActivity(intent);
    finish();
}

}

Upvotes: 0

Views: 108

Answers (2)

Shadow
Shadow

Reputation: 6899

Use this.

String barcodeType = rawResult.getBarcodeFormat().toString();

Upvotes: 2

Muhammad Waleed
Muhammad Waleed

Reputation: 2601

First you should be converted into string then compare these values
how to convert in to string

Upvotes: 0

Related Questions