Skip to content

Commit

Permalink
Add device info in crash screen
Browse files Browse the repository at this point in the history
  • Loading branch information
yogeshpaliyal committed Feb 7, 2022
1 parent baefa2f commit 37dea13
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion app/src/main/java/com/yogeshpaliyal/keypass/ui/CrashActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ package com.yogeshpaliyal.keypass.ui
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.yogeshpaliyal.keypass.BuildConfig
import com.yogeshpaliyal.keypass.databinding.ActivityCrashBinding
import dagger.hilt.android.AndroidEntryPoint
import java.lang.StringBuilder

@AndroidEntryPoint
class CrashActivity : AppCompatActivity() {
Expand All @@ -31,12 +34,30 @@ class CrashActivity : AppCompatActivity() {
binding.txtCrash.text = intent.extras?.getString(ARG_DATA)

binding.btnSendFeedback.setOnClickListener {

val deviceInfo = StringBuilder()
try {
deviceInfo.append("\n")
deviceInfo.append("App Version: " + BuildConfig.VERSION_NAME)
deviceInfo.append("\n")
deviceInfo.append("Brand Name: " + Build.BRAND)
deviceInfo.append("\n")
deviceInfo.append("Manufacturer Name: " + Build.MANUFACTURER)
deviceInfo.append("\n")
deviceInfo.append("Device Name: " + Build.MODEL)
deviceInfo.append("\n")
deviceInfo.append("Device API Version: " + Build.VERSION.SDK_INT)
deviceInfo.append("\n")
}catch (e:Exception){
e.printStackTrace()
}

val intent = Intent(Intent.ACTION_SENDTO)
intent.data = Uri.parse("mailto:")

intent.putExtra(Intent.EXTRA_EMAIL, arrayOf("yogeshpaliyal.foss@gmail.com"))
intent.putExtra(Intent.EXTRA_SUBJECT, "Crash Report in KeyPass")
intent.putExtra(Intent.EXTRA_TEXT, binding.txtCrash.text.toString())
intent.putExtra(Intent.EXTRA_TEXT, binding.txtCrash.text.toString() + "$deviceInfo")

startActivity(Intent.createChooser(intent, ""))
}
Expand Down

0 comments on commit 37dea13

Please sign in to comment.