Prizoff
Prizoff

Reputation: 4575

Detecting if device is from Samsung Galaxy family

Is there a reliable way of detecting if device is one from Samsung Galaxy phones? Currently, I do it in this way:

private static boolean isSamsungGalaxyN() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        try {
            PackageInfo info = getContext().getPackageManager().getPackageInfo("com.samsung.android.app.galaxyfinder", 0);
            if (info != null) {
                return true;
            }
        } catch (PackageManager.NameNotFoundException e) {
            // ignored
        }
    }
    return false;
}

So, I just check if there is such apk (which is S Finder, actually):

com.samsung.android.app.galaxyfinder

But is this method reliable and is there some better method?

Upvotes: 1

Views: 1654

Answers (1)

Gokul Nath KP
Gokul Nath KP

Reputation: 15563

Use Build.MANUFACTURER and Build.MODEL.

With Model you can get device family. For Galaxy S7 it will be SM-G903x. You need to have list of known Galaxy model names.

https://www.techwalls.com/samsung-galaxy-s7-edge-model-numbers-differences/

Upvotes: 2

Related Questions