/**
* 获取APP崩溃异常报告
*
* @param ex
* @return
*/
private String getCrashReport(Context context, Throwable ex) {
PackageInfo pinfo = getPackageInfo(context);
StringBuffer exceptionStr = new StringBuffer();
exceptionStr.append("Version: " + pinfo.versionName + "(" //当前应用的版本号。对应manifest中设置的版本号
+ pinfo.versionCode + ")\n");
exceptionStr.append("Android: " + android.os.Build.VERSION.RELEASE //系统的版本号
+ "(" + android.os.Build.MODEL + ")\n"); //手机型号
exceptionStr.append("Exception: " + ex.getMessage() + "\n");
StackTraceElement[] elements = ex.getStackTrace();
for (int i = 0; i < elements.length; i++) {
exceptionStr.append(elements[i].toString() + "\n");
}
return exceptionStr.toString();
}
/**
* 获取手机信息
*/
public void getPhoneInfo()
{
TelephonyManager tm = (TelephonyManager) this.getSystemService(TELEPHONY_SERVICE);
String mtyb = android.os.Build.BRAND;// 手机品牌
String mtype = android.os.Build.MODEL; // 手机型号
String imei = tm.getDeviceId();
String imsi = tm.getSubscriberId();
String numer = tm.getLine1Number(); // 手机号码
String serviceName = tm.getSimOperatorName(); // 运营商
tvPhoneInfo.setText("品牌: " + mtyb + "\n" + "型号: " + mtype + "\n" + "版本: Android " + android.os.Build.VERSION.RELEASE + "\n" + "IMEI: " + imei
+ "\n" + "IMSI: " + imsi + "\n" + "手机号码: " + numer + "\n" + "运营商: " + serviceName + "\n");
}