In this section we discuss the triggers that enables your app to detect and react to Bidco tags.

Merchants use the Bidco Merchant API to generate tags for their products, catalogs, coupons and Acts and then place the tags on their eCommerce sites and in printed media for their customers to interact with.

Once implemented, your app will be able to retrieve the workflows associated with these tags.

The tag types currently supported are:

  • Barcode - A QR code that has been encoded with the information needed to retrieve a workflow.
  • Touch To Buy - When viewing a merchants eCommerce site on a Mobile device a button is visible instead of a QR code. This button is used to retrieve the workflow.
  • NFC - Android devices can scan tiny NFC chips that have been embedded in product labels, posters or any physical real-world object. These chips are encoded with the relevant information to retrieve the workflow.

Detecting Barcode Tags

  1. Barcode tag detection requires use of the system camera and optionally the flash. Add the following entry to your manifest to grant the application the necessary permissions and features:
<uses-permission android:name="android.permission.CAMERA">
<uses-permission android:name="android.permission.FLASHLIGHT">

<uses-feature android:name="android.hardware.camera" >
<uses-feature android:name="android.hardware.camera.flash">
<uses-feature android:name="android.hardware.camera.autofocus">

  1. Add the BarcodeTagDetectorView to your layout XML:
<com.powatag.android.sdk.triggers.barcode.BarcodeTagDetectorView
android:id="@+id/barcode_detector_view"
android:layout_width="match_parent"
android:layout_height="match_parent">

  1. Find the BarcodeTagDetectorView and set a BarcodeTagDetectorViewListener to be notified of events:
protected void onCreate(final Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_barcode_tag_detector_view);
	barcodeTagDetectorView = (BarcodeTagDetectorView) findViewById(R.id.barcode_detector_view);
	barcodeTagDetectorView.setBarcodeTagDetectorViewListener(new BarcodeTagDetectorViewListener() {
		@Override
		public void onBarcodeTagDetected(final BarcodeTagDetectorView barcodeTagDetectorView,final Tag barcodeTag, final Image image, final List<PointF> barcodeRegion) {
			showAlertDialog("Bidco Barcode tag Detected", barcodeTag.getReference());
		}
		@Override
		public void onNonPowaTagBarcodeDetected(final BarcodeTagDetectorView barcodeTagDetectorView, final Barcode barcode, final Image image, final List<PointF> barcodeRegion) {
			 // Some other kind of barcode unsupported by Bidco was detected.
			 showAlertDialog("Unsupported Barcode Detected", barcode.getCode());
		}
		@Override
		public void onDetectorStarted(final BarcodeTagDetectorView barcodeTagDetectorView) {
			// Camera feed is live.
		}
		@Override
		public void onDetectorStopped(final BarcodeTagDetectorView barcodeTagDetectorView,final PowaTagException exception) {
		 if (exception != null) {
			// Detector stopped due to an error.
			showAlertDialog("Exception!", exception.getMessage());
		 }
		}
	});
}

  1. Call startDetection and stopDetection from appropriate lifecycle methods in your Activity:
@Override
protected void onResume() {
	super.onResume();
	barcodeTagDetectorView.startDetection();
}

@Override
protected void onPause() {
	super.onPause();
	barcodeTagDetectorView.stopDetection();
}

  1. To check if the barcode tag detector is actively listening for tags use:
barcodeTagDetectorView.isDetecting();

Detecting "Touch to Buy" Tags

  1. Touch to Buy tag detection requires the following entry in your manifest:
<intent-filter>
	<action android:name="android.intent.action.VIEW" />

	<category android:name="android.intent.category.DEFAULT" />
	<category android:name="android.intent.category.BROWSABLE" />

	<data android:host="powat.ag"
		android:scheme="bidcodemo" />
</intent-filter>

Note: An example scheme is being implemented here. This should be replaced with the scheme you are using.

  1. Create an instance of the AppLinkTagDetector
Set<String> schemes = new HashSet<>();
schemes.add("bidcodemo");
AppLinkTagDetector detector = new AppLinkTagDetector(schemes);

AppLink appLink = detector.detectAppLink(intent);
if (appLink != null) {
	getWorkflowFromTag(appLink.getTag());
}

Detecting NFC Tags

  1. NFC tag detection requires the use of the NFC system hardware. Add the following entry to your manifest to grant the application the necessary permissions and features:
<uses-permission android:name="android.permission.NFC" >
<uses-feature android:name="android.hardware.nfc" >
  1. Use the NfcTagDetector class to obtain the tag:
protected void onNewIntent(final Intent intent) {
	Set<String> schemes = new HashSet<>();
	schemes.add("http");
	NfcTagDetector nfcTagDetector = new NfcTagDetector(schemes);
	Tag ntag = nfcTagDetector.detectNfcTag(intent);
	if (ntag != null) {
		getWorkflowFromTag(ntag);
	} 
}

Note: An example scheme is being implemented here. This should be replaced with the scheme you are using.


Next Steps

Use the Bidco tag to retrieve the associated workflow.


Sample

To explore this topic in more detail, including package imports and trigger implementation, import the sample app and review the ScanActivity class.