Created
August 2, 2019 18:08
-
-
Save parzibyte/7b14f283e0e3fcf46f0d425d2f84865a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String obtenerNombreDeDispositivo() { | |
String fabricante = Build.MANUFACTURER; | |
String modelo = Build.MODEL; | |
if (modelo.startsWith(fabricante)) { | |
return primeraLetraMayuscula(modelo); | |
} else { | |
return primeraLetraMayuscula(fabricante) + " " + modelo; | |
} | |
} | |
private String primeraLetraMayuscula(String cadena) { | |
if (cadena == null || cadena.length() == 0) { | |
return ""; | |
} | |
char primeraLetra = cadena.charAt(0); | |
if (Character.isUpperCase(primeraLetra)) { | |
return cadena; | |
} else { | |
return Character.toUpperCase(primeraLetra) + cadena.substring(1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment