Skip to content

Instantly share code, notes, and snippets.

View agap's full-sized avatar
🏠
Working from home

Artem Gapchenko agap

🏠
Working from home
View GitHub Profile
package aga.android.migrations.sample
import aga.android.migrations.AndroidDatabaseSchema
import aga.android.migrations.sample.cache.Database.Companion.DB_VERSION
import aga.android.migrations.sample.cache.Database.Companion.build
import android.content.Context
import android.database.sqlite.SQLiteDatabase
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import io.requery.android.sqlite.DatabaseSource
val beaconScanner = BeaconScanner.Builder(this)
.setBeaconListener(
object : IBeaconListener {
override fun onBeaconEntered(beacon: Beacon) {
// do something with your beacon
}
override fun onBeaconExited(beacon: Beacon) {
// do something with your beacon
}
val beaconScanner = BeaconScanner.Builder(this)
.setBeaconBatchListener { beacons: Collection<Beacon> ->
// do something with your beacons here
}
.setRangingEnabled(
ArmaFilter.Builder()
)
.build()
beaconScanner.start()
val ranger = beaconScanner.getRanger()
val distance = ranger.calculateDistance(beacon)
val beaconScanner = BeaconScanner.Builder(this)
.setBeaconBatchListener { beacons: Collection<Beacon> ->
// do something with your beacons here
}
.setRangingEnabled()
.build()
val beaconLayout = "<beacon-layout>" // search the Internet to find the layout string of your specific beacon
val beaconParser = BeaconParserFactory.createFromLayout(beaconLayout)
val beaconScanner = BeaconScanner.Builder(this)
.setBeaconParser(beaconParser)
.setBeaconBatchListener { beacons: Collection<Beacon> ->
// do something with your beacons here
}
.build()
val region = Region.Builder()
.setNullField()
.setUuidField(UUID.fromString("01234567-0123-4567-89AB-456789ABCDEF"))
.setIntegerField(154)
.setIntegerField(10122)
.build()
val beaconScanner = BeaconScanner.Builder(this)
.setRegions(listOf(region))
.setBeaconBatchListener { beacons: Collection<Beacon> ->
override fun onResume() {
super.onResume()
beaconScanner.start()
}
override fun onPause() {
beaconScanner.stop()
super.onPause()
}
val beaconScanner = BeaconScanner.Builder(this)
.setBeaconBatchListener { beacons: Collection<Beacon> ->
// do something with your beacons here
}
.build()
Library AltBeacon iBeacon scanner android Luch
Different beacon layouts ❌ (iBeacons only) ✅ / ❌ (some limitations when compared to AltBeacon)
Works in background ✅ / ❌ (only via foreground services)
Distance calculation
Filters by beacon data
Detected beacons' caching