Setup¶
Installation¶
1. Add the Maven dependencies¶
tslocationmanager is published to Maven Central — no additional repository configuration required for modern Android projects (Maven Central is included by default in dependencyResolutionManagement / settings.gradle).
play-services-location is a transitive dependency of tslocationmanager, but declaring it explicitly lets you control the version.
| Dependency | Default | Browse versions |
|---|---|---|
com.transistorsoft:tslocationmanager |
4.0.+ |
central.sonatype.com |
com.google.android.gms:play-services-location |
21.3.0 |
maven.google.com |
Play Services v20 (legacy)
If your project targets Google Play Services ≤ 20 (rare for new projects), use the legacy artifact instead:
2. Permissions, services, and receivers¶
The library's AAR manifest automatically merges all required permissions, services, and receivers into your app. No manual AndroidManifest.xml entries are needed for the SDK itself.
Configure your license¶
Purchase a license
The SDK requires a license for release builds. Debug builds work without one. Purchase at transistorsoft.com.
Add the license key as <meta-data> inside the <application> element of your AndroidManifest.xml:
<manifest>
<application>
<meta-data
android:name="com.transistorsoft.locationmanager.license"
android:value="YOUR_LICENSE_KEY_JWT" />
</application>
</manifest>
Example¶
import com.transistorsoft.locationmanager.kotlin.BGGeo
import com.transistorsoft.locationmanager.kotlin.config.DesiredAccuracy
import com.transistorsoft.locationmanager.kotlin.config.LogLevel
// Application.onCreate() — initialize once
class MyApp : Application() {
override fun onCreate() {
super.onCreate()
BGGeo.init(this)
}
}
// Activity / Fragment — call ready() in a coroutine scope
class MainActivity : AppCompatActivity() {
private val subscriptions = mutableSetOf<EventSubscription>()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val bgGeo = BGGeo.instance
bgGeo.setActivity(this)
// Register event listeners *before* calling ready()
bgGeo.onLocation { event ->
Log.d(TAG, "[onLocation] ${event.coords}")
}.storeIn(subscriptions)
lifecycleScope.launch {
// ready() configures the SDK and restores persisted state.
// It does NOT start tracking — call start()/stop() separately.
bgGeo.ready {
geolocation.desiredAccuracy = DesiredAccuracy.HIGH
geolocation.distanceFilter = 10f
app.stopOnTerminate = false
app.startOnBoot = true
logger.debug = true
logger.logLevel = LogLevel.VERBOSE
}
}
}
// Elsewhere — e.g. a toggle-button click listener in your UI
private fun onToggleTracking() {
lifecycleScope.launch {
val bgGeo = BGGeo.instance
val state = bgGeo.state
if (state.enabled) {
bgGeo.stop()
} else {
bgGeo.start()
}
Log.d(TAG, "[state] enabled=${state.enabled} trackingMode=${state.trackingMode}")
}
}
override fun onDestroy() {
subscriptions.forEach { it.close() }
subscriptions.clear()
super.onDestroy()
}
}