publicintobtainApiLevel(){intret=0;if(0==ret){try{// SDK_INT only exists since API 4 so let's use the string versionret=Integer.parseInt(android.os.Build.VERSION.SDK);}catch(Exceptione){ret=3;}}// another method// android.provider.Settings.System.getInt(this.getContentResolver(),// android.provider.Settings.System.SYS_PROP_SETTING_VERSION);// another method// getPackageManager().getPackageInfo(getPackageName(),0).applicationInfo.targetSdkVersion;Log.d(TAG,"obtainApiLevel()="+ret);returnret;}