Get the current app version number and system version number

Source: Internet
Author: User

/**
* Get app Crash exception report
*
* @param ex
* @return
*/
Private String Getcrashreport (context context, throwable ex) {
PackageInfo pinfo = getpackageinfo (context);
StringBuffer exceptionstr = new StringBuffer ();
Exceptionstr.append ("Version:" +Pinfo.versionname+ "("//version number of the current app.) Corresponds to the version number set in the manifest
+ Pinfo.versioncode + ") \ n");
Exceptionstr.append ("Android:" +Android.os.Build.VERSION.RELEASEVersion number of the system
+ "(" +Android.os.Build.MODEL+ ") \ n"); Phone model
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 ();
}

/**
* Get Mobile Information
*/
public void Getphoneinfo ()
{
Telephonymanager TM = (Telephonymanager) this.getsystemservice (Telephony_service);
String mtyb = android.os.build.brand;//phone Brand
String mtype = Android.os.Build.MODEL; Phone model
String IMEI = Tm.getdeviceid ();
String IMSI = Tm.getsubscriberid ();
String Numer = Tm.getline1number (); Mobile phone number
String serviceName = Tm.getsimoperatorname (); Operators
Tvphoneinfo.settext ("Brand:" + mtyb + "\ n" + "model:" + mtype + "\ n" + "version: Android" + Android.os.Build.VERSION.RELEASE + "\ n "+" IMEI: "+ IMEI
+ "\ n" + "IMSI:" + IMSI + "\ n" + "mobile number:" + Numer + "\ n" + "operator:" + serviceName + "\ n");
}

Get the current app version number and system version number

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.