2010-08-29 4 views

Répondre

84

Tout d'abord, un coup d'oeil à ces classes "Build" à la page android-sdk: http://developer.android.com/reference/android/os/Build.html.

// Device model 
String PhoneModel = android.os.Build.MODEL; 

// Android version 
String AndroidVersion = android.os.Build.VERSION.RELEASE; 
+0

Merci pour votre aide. Je l'ai essayé très longtemps mais je n'ai pas pu trouver cette réponse. Alors merci pour votre aide et je vous accorde +1 pour une aide précieuse. – Aditya1510

+2

@ Aditya1510 Thand et heureux que ma réponse vous soit utile. :) –

0

Je recommande la bibliothèque ouverte « caféine », Cette bibliothèque contient obtenir le nom de l'appareil, ou modèle, ont SD contrôle de la carte, et de nombreuses fonctionnalités.

cette bibliothèque est ici.

https://github.com/ShakeJ/Android-Caffeine-library

Et vous utilisez par exemple 'SystemUtil',

SystemUtil.modelName(); 
1

// Obtenir Modèle de l'appareil, Fabricant, version Android OS et id appareil:

public String getDeviceName() { 

    String manufacturer = Build.MANUFACTURER; 
    String model = Build.MODEL; 

    if (model.startsWith(manufacturer)) { 
     return capitalize(model); 
    } else { 
     return capitalize(manufacturer) + " " + model; 
    } 
} 

private String getAndroidVersion() { 
    return android.os.Build.VERSION.RELEASE; 
} 

private String capitalize(String s) { 
    if (s == null || s.length() == 0) { 
     return ""; 
    } 
    char first = s.charAt(0); 
    if (Character.isUpperCase(first)) { 
     return s; 
    } else { 
     return Character.toUpperCase(first) + s.substring(1); 
    } 
} 

private String getDeviceId() { 
    String deviceId = ""; 
    final TelephonyManager mTelephony = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); 
    if (mTelephony.getDeviceId() != null) { 
     deviceId = mTelephony.getDeviceId(); 
    } else { 
     deviceId = Secure.getString(getApplicationContext() 
       .getContentResolver(), Secure.ANDROID_ID); 
    } 
    return deviceId; 
} 
9
String s="Debug-infos:"; 
     s += "\n OS Version: " + System.getProperty("os.version") + "(" + android.os.Build.VERSION.INCREMENTAL + ")"; 
     s += "\n OS API Level: "+android.os.Build.VERSION.RELEASE + "("+android.os.Build.VERSION.SDK_INT+")"; 
     s += "\n Device: " + android.os.Build.DEVICE; 
     s += "\n Model (and Product): " + android.os.Build.MODEL + " ("+ android.os.Build.PRODUCT + ")"; 
+0

quelle est la différence entre android.os.Build.VERSION.RELEASE et android.os.Build.VERSION.SDK_INT? – Exigente05

+0

@ Exigente05 Version liée à la version de l'application alors que SDK_INT se rapporte à la version SDK. – Ajay

Questions connexes