]> git.ktnx.net Git - mobile-ledger.git/commitdiff
add MoLe version to the crash report
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Wed, 5 Jun 2019 18:27:50 +0000 (21:27 +0300)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Wed, 5 Jun 2019 18:27:50 +0000 (21:27 +0300)
app/src/main/java/net/ktnx/mobileledger/ui/activity/CrashReportingActivity.java

index 24b50fa74db0d3d7a02d39764e346e0195c55cf2..183a5e9184d84ad0ec847a507e013d17f75ff791 100644 (file)
 
 package net.ktnx.mobileledger.ui.activity;
 
+import android.content.pm.PackageInfo;
 import android.os.Build;
 import android.os.Bundle;
 import android.util.Log;
 
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AppCompatActivity;
+
 import net.ktnx.mobileledger.ui.CrashReportDialogFragment;
 
 import java.io.PrintWriter;
 import java.io.StringWriter;
 
-import androidx.annotation.Nullable;
-import androidx.appcompat.app.AppCompatActivity;
-
 import static net.ktnx.mobileledger.utils.Logger.debug;
 
 public abstract class CrashReportingActivity extends AppCompatActivity {
@@ -42,6 +43,16 @@ public abstract class CrashReportingActivity extends AppCompatActivity {
                 StringWriter sw = new StringWriter();
                 PrintWriter pw = new PrintWriter(sw);
 
+                try {
+                    PackageInfo pi = getApplicationContext().getPackageManager()
+                            .getPackageInfo(getPackageName(), 0);
+                    pw.format("MoLe version: %s\n", pi.versionName);
+                }
+                catch (Exception oh) {
+                    pw.print("Error getting package version:\n");
+                    oh.printStackTrace(pw);
+                    pw.print("\n");
+                }
                 pw.format("OS version: %s; API level %d\n\n", Build.VERSION.RELEASE,
                         Build.VERSION.SDK_INT);
                 e.printStackTrace(pw);