Get Android Phone Model programmatically , How to get Device name and model programmatically in android?
On many popular devices the market name of the device is not available. For example, on the Samsung Galaxy S6 the value of Build.MODEL
could be "SM-G920F"
, "SM-G920I"
, or "SM-G920W8"
.
I created a small library that gets the market (consumer friendly) name of a device. It gets the correct name for over 10,000 devices and is constantly updated. If you wish to use my library click the link below:
AndroidDeviceNames Library on Github
If you do not want to use the library above, then this is the best solution for getting a consumer friendly device name:
/** Returns the consumer friendly device name */
public static String getDeviceName() {
String manufacturer = Build.MANUFACTURER;
String model = Build.MODEL;
if (model.startsWith(manufacturer)) {
return capitalize(model);
}
return capitalize(manufacturer) + " " + model;
}
private static String capitalize(String str) {
if (TextUtils.isEmpty(str)) {
return str;
}
char[] arr = str.toCharArray();
boolean capitalizeNext = true;
StringBuilder phrase = new StringBuilder();
for (char c : arr) {
if (capitalizeNext && Character.isLetter(c)) {
phrase.append(Character.toUpperCase(c));
capitalizeNext = false;
continue;
} else if (Character.isWhitespace(c)) {
capitalizeNext = true;
}
phrase.append(c);
}
return phrase.toString();
}
Example from my Verizon HTC One M8:
// using method from above
System.out.println(getDeviceName());
// Using https://github.com/jaredrummler/AndroidDeviceNames
System.out.println(DeviceName.getDeviceName());
Result:
HTC6525LVW
HTC One (M8)
How to get the device Model Name?
It was really simple, just call:
String model = Build.MODEL;
Update: This code will print the exact string you requested:
String reqString = Build.MANUFACTURER
+ " " + Build.MODEL + " " + Build.VERSION.RELEASE
+ " " + Build.VERSION_CODES.class.getFields()[android.os.Build.VERSION.SDK_INT].getName();
Prints:
Samsung Note 4 6.0 MARSHMALLOW
LGE LG-D410 4.4.2 KITKAT
Get Android Device Name
In order to get Android device name you have to add only a single line of code:
android.os.Build.MODEL;
Found here: getting-android-device-name
How to detect a mobile device manufacturer and model programmatically in Android?
You can get as below:
String deviceName = android.os.Build.MODEL;
String deviceMan = android.os.Build.MANUFACTURER;
For more other device details, Please refer this document: android.os.Build
How can I get the device name in Android?
To display the device name/model in android use:
TextView tv1 = (TextView) findViewById(R.id.tv1);
String str = android.os.Build.MODEL;
tv1.setText(str);
Link to Android Build Class
Get Android Phone Specs Programmatically
You should look into Google Analytics. They probably have what you need for your app. But if you're going to change User Experience depending on the phone they use, these links could help:
Android: Get Hardware Information Programmatically
Get Android Phone Model Programmatically
Try these:
Log.i("TAG", "SERIAL: " + Build.SERIAL);
Log.i("TAG","MODEL: " + Build.MODEL);
Log.i("TAG","ID: " + Build.ID);
Log.i("TAG","Manufacture: " + Build.MANUFACTURER);
Log.i("TAG","brand: " + Build.BRAND);
Log.i("TAG","type: " + Build.TYPE);
Log.i("TAG","user: " + Build.USER);
Log.i("TAG","BASE: " + Build.VERSION_CODES.BASE);
Log.i("TAG","INCREMENTAL " + Build.VERSION.INCREMENTAL);
Log.i("TAG","SDK " + Build.VERSION.SDK);
Log.i("TAG","BOARD: " + Build.BOARD);
Log.i("TAG","BRAND " + Build.BRAND);
Log.i("TAG","HOST " + Build.HOST);
Log.i("TAG","FINGERPRINT: "+Build.FINGERPRINT);
Log.i("TAG","Version Code: " + Build.VERSION.RELEASE);
Related Topics
Decrease Image Size Without Losing Its Quality in Android
Flutter:Renderbox Was Not Laid Out: Renderrepaintboundary#58C65 Relayoutboundary=Up1 Needs-Paint
Java.Lang.Runtimeexception: Canvas: Trying to Draw Too Large(144000000Bytes) Bitmap
How to Reduce an Image File Size Before Uploading to a Server
How to Know Location Area Code and Cell Id in Android Phone
Clear Cache in Android Application Programmatically
How to Avoid Overlap View in Relative Layout in Android
Remove Old and Add New Git in Android Studio
How to Remove the Black Bar Appearing At the Bottom
Socket.Io Client Getting Connected Disconnected Repeatedly
How to Change Background Color of Layout of List-View Item Using Array-Adapter
How to Change Styling of Textinput Placeholder in React Native
How to Use Python to Execute Adb Commands
Android Force Gpu Rendering How to Enable and Disable
How to Validate Password Field in Android
How to Close the Current Fragment by Using Button Like the Back Button