Android开发中常用到方法总结 第2页
.getSystemService(Context.TELEPHONY_SERVICE);//
String str = "";
str += "DeviceId(IMEI) = " + tm.getDeviceId() + "\n";
str += "DeviceSoftwareVersion = " + tm.getDeviceSoftwareVersion()
+ "\n";
str += "Line1Number = " + tm.getLine1Number() + "\n";
str += "NetworkCountryIso = " + tm.getNetworkCountryIso() + "\n";
str += "NetworkOperator = " + tm.getNetworkOperator() + "\n";
str += "NetworkOperatorName = " + tm.getNetworkOperatorName() + "\n";
str += "NetworkType = " + tm.getNetworkType() + "\n";
str += "honeType = " + tm.getPhoneType() + "\n";
str += "SimCountryIso = " + tm.getSimCountryIso() + "\n";
str += "SimOperator = " + tm.getSimOperator() + "\n";
str += "SimOperatorName = " + tm.getSimOperatorName() + "\n";
str += "SimSerialNumber = " + tm.getSimSerialNumber() + "\n";
str += "SimState = " + tm.getSimState() + "\n";
str += "SubscriberId(IMSI) = " + tm.getSubscriberId() + "\n";
str += "VoiceMailNumber = " + tm.getVoiceMailNumber() + "\n";
return str;
}
7.得到软件版本信息学习林俊德心得体会
public static String getSoftwareVersion(Context ctx) {
String version = "";
try {
PackageInfo packageInfo = ctx.getPackageManager().getPackageInfo(
ctx.getPackageName(), 0);
version = packageInfo.versionName;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
return version;
}
8.得到当前日期
public static String getCurrDate(String format) {
String str_format = (format == null || format == "") ? "yyyy-MM-dd HH:mm:ss"
: format;
Date date = new Date();
SimpleDateFormat from = new SimpleDateFormat(str_format);
String times = from.format(date);
return times;
}
9.根据URL获取bitmap
public static Bitmap getURLBitmap(String uriPic) throws Exception {
URL imageUrl = null;
Bitmap bitmap = null;
try {
imageUrl = new URL(uriPic);
} catch (MalformedURLException e) {
e.printStackTrace();
}
try {
HttpURLConnection conn = (HttpURLConnection) imageUrl
.openConnection();
conn.setConnectTimeout(5*1000);
conn.setReadTimeout(5*1000);
conn.setDoInput(true);
conn.setDoOutput(true);
conn.setUseCaches(true);
conn.setRequestMethod("POST");
conn.connect();
InputStre