Get Operating System version via code

Basic Tutorials concerning: GUI, Views, Activites, XML, Layouts, Intents, ...

Get Operating System version via code

Postby csengyee » Mon Jan 25, 2010 1:54 pm

Which class should I use to obtain current Operating System version that is running on the mobile device?

Please help. Thanks.
csengyee
Junior Developer
Junior Developer
 
Posts: 19
Joined: Mon Jul 13, 2009 3:07 pm

Top

Postby vikikivi » Fri Feb 19, 2010 12:10 am

Kinda late but i used the following and works perfectly with G1, myTouch 3G, Moto Droid 1.6-2.1 so far.

A support email that I composed for my app.

Code: Select all
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String number = tm.getLine1Number();
String OSversion = tm.getDeviceSoftwareVersion();
String carrier = tm.getNetworkOperatorName();
int phonetype_t = tm.getPhoneType();
String phonetype = "";
int networktype_t = tm.getNetworkType();

if ("".equals(number))
   number = appSettings.getString("my_phoneno");

switch (phonetype_t) {
        case 0:
      phonetype = "UNKNOWN";
      break;
   case 1:
      phonetype = "GSM";
      break;
   case 2:
      phonetype = "CDMA";
      break;
   default:
      phonetype = "UNKNOWN";
}

Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_EMAIL,
   new String[] { "support@blahblah.com" });
         sendIntent.putExtra(Intent.EXTRA_TEXT,
               "<Type your Issue or Comment here>nnn"
               + "--------------------n"
               + "DON'T DELETE BELOW THISn" + "App Version: 2.0"
               + "nNumber: "   + number
               + "nAndroid OS: " + Build.VERSION.RELEASE
               + "nCarrier: "+ carrier
               + "nManufacturer: "   + Build.MANUFACTURER
               + "nModel: " + Build.MODEL
               + "nPhone Type: " + phonetype
               + "nNetwork Type: "    + networktype_t
               + "nMISC: " + "device=" + Build.DEVICE+ "&"
               + "disp=" + Build.DISPLAY
               + "&" + "brand=" + Build.BRAND);
vikikivi
Freshman
Freshman
 
Posts: 7
Joined: Fri Jan 22, 2010 1:19 pm

Top

Return to Novice Tutorials

Who is online

Users browsing this forum: No registered users and 7 guests