From 9444b6123710997425d2f311d5dd97c6590aebca Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Wed, 5 Jun 2019 21:27:50 +0300 Subject: [PATCH] add MoLe version to the crash report --- .../ui/activity/CrashReportingActivity.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/CrashReportingActivity.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/CrashReportingActivity.java index 24b50fa7..183a5e91 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/activity/CrashReportingActivity.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/CrashReportingActivity.java @@ -17,18 +17,19 @@ 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); -- 2.39.5