Starting with Android 12 (API31), there is a requirement for many App permissions to be obtained from the user at run-time.
You will need to be using the TSL ASCII 2 Software Development Kit – for Android™ v2.5.0 or greater to add support for Android 12 (or greater) devices.
To support the (API31+) requirement of User permission checks, your app will need to issue a request for Bluetooth® permissions where appropriate. If this is not done, then Bluetooth® readers will NOT BE AVAILABLE – e.g. calls to ReaderManager.sharedInstance().updateList()
will return an empty list.
The Android developer guide to requesting permissions is available here:
https://developer.android.com/guide/topics/permissions/overview
Run-Time Permissions Required
The new permissions to be requested are:
Manifest.permission.BLUETOOTH_CONNECT
Manifest.permission.BLUETOOTH_SCAN
Note: Manifest declarations are still also required. The Rfid.AsciiProtocol-Library
contains its own android_manifest.xml
that will be merged with your project’s android_manifest.xml
when your project is built. The library provides both the original Bluetooth® permissions for older devices along with the newer permissions shown above.
At an appropriate point in your application, ask the user for the above permissions. The permissions dialog will be provided by the OS and often refers to “nearby devices” rather than mentioning Bluetooth® specifically. You may want to warn your users that allowing this permission is required to connect to TSL® Readers via Bluetooth®.
When permissions have been granted, call ReaderManager.sharedInstance().updateList()
to ensure the reader list is up to date. The Android SDK’s sample projects have all been updated with examples of how this can be done – there are slight differences in implementation details due to the differing UIs, but the code is mostly identical.
The Sample code implementation asks for permission in the onStart()
lifecycle method of the apps Activity, but you may find a better place in your own apps if use of the TSL Reader is not .
The implementation of the checkForBluetoothPermission()
method can be found at the end of the sample project’s Activity source file.
By following the above advice, owners of the latest Android devices can continue to enjoy using your RFID App with their TSL® RFID Reader.