The Open Anonymous Device Identifier for Android. More infomation see Compatibility list
Download the dependency from JitPack using Gradle.
// build.gradle(Project)
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
// build.gradle(:app)
dependencies {
implementation "com.github.phantomVK:Identifier:latest.release@aar"
}
Add following code to app's Application.class to init IdentifierManager. Those code takes no time to execute, keep it run on the main thread is fine.
class Application : android.app.Application() {
override fun onCreate() {
super.onCreate()
IdentifierManager.Builder(applicationContext)
.setDebug(false)
.setExperimental(false)
.setLimitAdTracking(false)
.setMemCacheEnable(true)
.setExecutor { Thread(it).start() } // optional: setup custom ThreadPoolExecutor
.setLogger(LoggerImpl())
.init()
}
}
How to query the latest oaid:
val listener = object : OnResultListener {
override fun onSuccess(result: IdentifierResult) {}
override fun onError(msg: String, t: Throwable?) {}
}
IdentifierManager
.getInstance()
.setSubscriber(listener)
.enableAaid(false)
.enableVaid(false)
.enableGoogleAdsId(false) // optional: use GoogleAdsId as backup, default is false
.subscribe()
Copyright 2024 WenKang Tan(phantomVK)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.