Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

476
Vistas
Android and Kotlin varargs: formatted strings returns garbage

I'm encountering a strange problem: I've a general function which is used to retrieve resource strings (it's just to avoid writing context.resources.getString() everytime):

protected fun string(@StringRes stringRes: Int, vararg args: String): String = app.getString(stringRes, args) 

worked fine up until now, when I added the varargs to retrieve formatted strings. Simple strings still work fine but when I tried to retrieve a formatted one:

string(R.string.formatted_string, myId)

my string resource:

<string name="formatted_string">#%s</string>

I get some garbage:

#[Ljava.lang.String;@3a59711

expected:

#4848684

the garbage change with the resource I request

It looks a Object identifier.

If I don't use the method it works fine

What is happening here?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

The solution for you is to use the spread operator *:

fun string(@StringRes stringRes: Int, vararg args: String): String = getString(stringRes, *args)

Variable number of arguments (Varargs)

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda