2

As I have refer the old post i.e. Android: Get Hardware Information Programmatically but didn't find any relavant answer and also tried to find the solution in google but all in vain. Please help me go forward

enter image description here

Community
  • 1
  • 1
Rajat kumar
  • 884
  • 9
  • 25

3 Answers3

3

I recently setup such a thing... Upon registration, the phone sends to the webservice (with Retrofit) all the useful harware / software parameters I could find... Here is the relevant part of the code I used :

boolean isRooted = findBinary("su");
PackageInfo pInfo;
String version = "unknown";
try {
    pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
    version = pInfo.versionName;
} catch (NameNotFoundException e) {
    e.printStackTrace();
}

myService.sendPhoneDetails(
    android.os.Build.VERSION.SDK_INT,
    android.os.Build.VERSION.RELEASE,
    android.os.Build.BRAND,
    android.os.Build.MANUFACTURER,
    android.os.Build.MODEL,
    android.os.Build.SERIAL,
    isRooted,
    version,
    new Callback<Model>() {
        @Override
            public void success(Model model, Response response) {
                // ....
            }
        @Override
            public void failure(RetrofitError error) {
                // ....
            }
        }
    );

private static boolean findBinary(String binaryName) {
    boolean found = false;
    if (!found) {
        String[] places = { "/sbin/", "/system/bin/", "/system/xbin/",
                "/data/local/xbin/", "/data/local/bin/",
                "/system/sd/xbin/", "/system/bin/failsafe/", "/data/local/" };
        for (String where : places) {
            if (new File(where + binaryName).exists()) {
                found = true;

                break;
            }
        }
    }
    return found;
}

Note that all the phones do not give access to the same info, like the phone number rarely accessible, but those ones look pretty common.

Hope this can help...

JBA
  • 2,889
  • 1
  • 21
  • 38
2

Using Build class you can get all of this information.

to write down those info in a Toast (For Example) you can use:

Toast.makeText(getApplicationContext(), ""+Build.HARDWARE+Build.DEVICE+Build.MANUFACTURER+ "etc..", Toast.LENGTH_SHORT).show();

for more info about the build class check out the link above.

hope this will help.

Ahmad Sanie
  • 3,678
  • 2
  • 21
  • 56
1

You can read /proc/meminfo and /proc/cpuinfo for example. These do not require root access and contain information about the memory / cpu.

Details on how to read these can be found here: Any way to run shell commands on android programmatically?

Community
  • 1
  • 1
davidgiga1993
  • 2,695
  • 18
  • 30