An Android Quuppa Tag emulation library to be included into Android application projects. You can make any Android device with BLE and API level 26 (Android version 8.0+) trackable in Quuppa Intelligent Locating System by including this library in your Android application.
See the android-quuppa-tag demo for an example of how to use this library. Also check out javadoc for the library on javadoc.io.
The library is ready to be included in your Android project as a compiled dependency and available as a JAR dependency through Maven central.
The library requires several permissions:
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CONNECTED_DEVICE" />
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
REQUEST_IGNORE_BATTERY_OPTIMIZATIONS is a UI permission (again see android-quuppa-tag demo app) but in order to make sure the OS doesn't kill the service when the app is not on the foreground, you should disable battery optimizations. You also need to declare the service and receiver as described in the demo app's AndroidManifest.xml.
The 1.x version of the library provided simple operations in a stateless utility class and required user to implement a service around it to make it run for longer periods. The current 2.x version implements a full service that also uses the accelerometer to determine whether the device is moving or not.
The service is very simple to use. However, it's not enough just to:
Intent tagServiceIntent = new Intent(this, QuuppaTagService.class);
startForegroundService(tagServiceIntent);
You should first call QuuppaTag.setServiceEnabled(context, true);
to set the service in enabled state. This is so that service can automatically start on system events but only acquires the wake lock and starts emitting BLE advertisement packets when in enabled state. The class QuuppaTag also contains getters and setters for other parameters, such as a the tag ID and AdvertisingSet TX power. The default tag ID (based on Secure.ANDROID_ID if available) is guaranteed to stay constant for the lifetime of the application but you can also supply your own ID if you so prefer.
This library is really not so useful outside Real-Time Locationing System (RTLS) scope. Even so, it may give you ideas for creating your own never ending service that can ben run on modern Android devices (because Google has been tightening rules around long running service all the time). In short, it's a combination of implementing a frontend service (which this library does), holding a wake lock and disabling battery optimizations - look for examples in the demo app for permission requests. Feel free to explore the source code.
Licensed under Apache 2.0 License.