The RFID V2 app provides a new activity that you can call if you want to receive data in your code, but do not want to build your own user interface.
You can start the activity with startActivityForResult and data will be returned in onActivityResult. This means that this feature is also compatible with the newer Activity Result APIs.
The activity is started with startActivityForResult:
1 2 3 |
Intent intent = new Intent("com.handheldgroup.rfid.SCAN"); intent.setPackage("com.handheldgroup.rfid"); startActivityForResult(intent, 2522); |
If the app has not been configured for a specific module, you will need to provide a string extra with the key module. See below for possible values.
There are other optional string extras that you can provide:
Key | Description |
message | A message to show to the user. Default is empty |
title | Title shown in the window. Default is “RFID Scan” |
cancel | Text for the cancel button. Default is “Cancel” |
color | Accent color in “#XXXXXX” format. Default is “#2e99d5” |
After a successful scan, any error, if the user pressed “Cancel”, or when the user pressed the back button, the activity closes
and triggers onActivityResult on the activity that called startActivityForResult.
The resultCode code will be RESULT_CANCELED if the user canceled the scan and RESULT_OK in any other case.
The data parameter contains a boolean extra with the success which indicates a successful scan or and error.
If the scan was successful, the string extra id contains the ID of the tag. Otherwise the string extra error contains the error message that occurred.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
@Override protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); TextView status = findViewById(R.id.status); if (resultCode == Activity.RESULT_OK) { boolean success = data.getBooleanExtra("success", false); if (success) { status.setText("OK - " + data.getStringExtra("id")); } else { status.setText("Error - " + data.getStringExtra("error")); } } else { status.setText("Canceled by user"); } } |
Options for module extra
Both the startService
and startActivityForResult
intent support a module
extra with one of
the following values.
- NX2-1030: For the Elatec Module on the Nautiz X2 with Android 6, 7, or 11
- NX2EXP-LF: For the iDTRONIC IDT01 on the Nautiz X2 with Android 6, 7, or 11
- NX2-EU-1043: For the Pistol Grip UHF (EU) on the Nautiz X2 with Android 6, 7, or 11
- NX2-NA-1043: For the Pistol Grip UHF (NA) on the Nautiz X2 with Android 6, 7, or 11
- NX6EXP-LF01: For the Agrident Module on the Nautiz X6v1 with Android 8
- NX6EXP-LF02: For the Elatec Module on the Nautiz X6v1 with Android 8
- NX6V2EXP-LF01: For the Agrident Module on the Nautiz X6v2 with Android 11
- NX6V2EXP-LF02: For the Elatec Module on the Nautiz X6v2 with Android 11