1

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?

Prizoff
  • 4,486
  • 4
  • 41
  • 69
  • 1
    Already asked questions. check this out https://stackoverflow.com/questions/1995439/get-android-phone-model-programmatically – Gajendra Singh Rathore Aug 27 '18 at 19:42
  • Specified question asks another question (I do not need user readable device name), but the lib from accepted answer appears to be the good alternative solution, thanks! – Prizoff Aug 27 '18 at 19:55
  • May be there is a solution which uses one of Samsung Developers SDKs? Was not able to find one appropriate... – Prizoff Aug 27 '18 at 20:06
  • This link shows you the full list of samsung galaxy phones with more details, hope you can find inspiration. https://en.wikipedia.org/wiki/Samsung_Galaxy – Run Aug 28 '18 at 03:39

1 Answers1

1

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/

Gokul Nath KP
  • 15,485
  • 24
  • 88
  • 126
  • And how should I use them to get to know that device is for example Samsung Galaxy S7? – Prizoff Aug 27 '18 at 19:55
  • S7... S8, and S9 and future S10... and even maybe S6. And not necessery any Sx. Samsung Galaxy Xcover and any other Galaxy devices should produce positive results too. So, using Build.MODEL is not acceptable here (except only in case if you have big enough name database, which specified library from other question provides). – Prizoff Aug 27 '18 at 20:04