Andrew Walsh
Andrew Walsh

Reputation: 35

Fetching Android ID with Kotlin for a webapp

I can only find guides for javascript implementations of what I am trying to do. I need to pull some sort of unique ID and send it to my web app for Auth verification.

The error I am receiving is

in MainActivity.kt: (22, 29): Unresolved reference: Settings

This is my MainActivity.kt

import android.provider.Settings.Secure;

class MainActivity : AppCompatActivity() {

    private val androidId = Settings.Secure.getString(
    contentResolver,
    Settings.Secure.ANDROID_ID
    )
}

For now I just want to be able to tack on the device_id as a php variable for my web app. Something like below:

private val url = "https://test.local?id=" + androidId

Upvotes: 0

Views: 1961

Answers (1)

TheWanderer
TheWanderer

Reputation: 17834

You've imported android.provider.Settings.Secure, not android.provider.Settings.

Either change your import to android.provider.Settings or use Secure.ANDROID_ID instead of Settings.Secure.ANDROID_ID.

Upvotes: 2

Related Questions