Kotlin allows for even simpler code than what's shown in other answers.
To get the new token whenever it's refreshed:
class MyFirebaseMessagingService: FirebaseMessagingService() {
override fun onNewToken(token: String?) {
Log.d("FMS_TOKEN", token)
}
...
}
To get the token from anywhere at runtime:
FirebaseInstanceId.getInstance().instanceId.addOnSuccessListener {
Log.d("FMS_TOKEN", it.token)
}